@@ -119,7 +119,7 @@ def _generate_and_write_metadata(rolename, metadata_filename,
119
119
120
120
121
121
elif rolename == 'snapshot' :
122
- metadata = generate_snapshot_metadata (metadata_directory ,
122
+ metadata , fileinfodict = generate_snapshot_metadata (metadata_directory ,
123
123
roleinfo ['version' ], roleinfo ['expires' ],
124
124
storage_backend , consistent_snapshot , repository_name ,
125
125
use_length = use_snapshot_length , use_hashes = use_snapshot_hashes )
@@ -128,10 +128,10 @@ def _generate_and_write_metadata(rolename, metadata_filename,
128
128
root , leaves = _build_rsa_acc (fileinfodict )
129
129
130
130
# Add the rsa accumulator to the timestamp roleinfo
131
- timestamp_roleinfo = tuf . roledb .get_roleinfo ('timestamp' , repository_name )
131
+ timestamp_roleinfo = roledb .get_roleinfo ('timestamp' , repository_name )
132
132
timestamp_roleinfo ['rsa_acc' ] = root
133
133
134
- tuf . roledb .update_roleinfo ('timestamp' , timestamp_roleinfo ,
134
+ roledb .update_roleinfo ('timestamp' , timestamp_roleinfo ,
135
135
repository_name = repository_name )
136
136
137
137
@@ -145,7 +145,8 @@ def _generate_and_write_metadata(rolename, metadata_filename,
145
145
146
146
metadata = generate_timestamp_metadata (snapshot_file_path , roleinfo ['version' ],
147
147
roleinfo ['expires' ], storage_backend , repository_name ,
148
- use_length = use_timestamp_length , use_hashes = use_timestamp_hashes )
148
+ use_length = use_timestamp_length , use_hashes = use_timestamp_hashes ,
149
+ roleinfo = roleinfo )
149
150
150
151
_log_warning_if_expires_soon (TIMESTAMP_FILENAME , roleinfo ['expires' ],
151
152
TIMESTAMP_EXPIRES_WARN_SECONDS )
@@ -393,6 +394,8 @@ def _delete_obsolete_metadata(metadata_directory, snapshot_metadata,
393
394
for metadata_role in metadata_files :
394
395
if metadata_role .endswith ('root.json' ):
395
396
continue
397
+ if metadata_role .endswith ('-snapshot.json' ):
398
+ continue
396
399
397
400
metadata_path = os .path .join (metadata_directory , metadata_role )
398
401
@@ -1697,9 +1700,8 @@ def _write_rsa_proofs(root, leaves, storage_backend, rsa_acc_directory, version)
1697
1700
1698
1701
for l in leaves :
1699
1702
# Write the leaf to the rsa_acc_directory
1700
- print (l )
1701
- file_contents = tuf .formats .build_dict_conforming_to_schema (
1702
- tuf .formats .SNAPSHOT_RSA_ACC_SCHEMA ,
1703
+ file_contents = formats .build_dict_conforming_to_schema (
1704
+ formats .SNAPSHOT_RSA_ACC_SCHEMA ,
1703
1705
leaf_contents = l .contents ,
1704
1706
rsa_acc_proof = str (l .proof ))
1705
1707
file_content = _get_written_metadata (file_contents )
@@ -1861,19 +1863,22 @@ def generate_snapshot_metadata(metadata_directory, version, expiration_date,
1861
1863
# generate_root_metadata, etc. with one function that generates
1862
1864
# metadata, possibly rolling that upwards into the calling function.
1863
1865
# There are very few things that really need to be done differently.
1864
- return formats .build_dict_conforming_to_schema (
1866
+ metadata = formats .build_dict_conforming_to_schema (
1865
1867
formats .SNAPSHOT_SCHEMA ,
1866
1868
version = version ,
1867
1869
expires = expiration_date ,
1868
1870
meta = fileinfodict )
1869
1871
1872
+ return metadata , fileinfodict
1873
+
1870
1874
1871
1875
1872
1876
1873
1877
1874
1878
1875
1879
def generate_timestamp_metadata (snapshot_file_path , version , expiration_date ,
1876
- storage_backend , repository_name , use_length = True , use_hashes = True ):
1880
+ storage_backend , repository_name , use_length = True , use_hashes = True ,
1881
+ roleinfo = None ):
1877
1882
"""
1878
1883
<Purpose>
1879
1884
Generate the timestamp metadata object. The 'snapshot.json' file must
@@ -1952,8 +1957,8 @@ def generate_timestamp_metadata(snapshot_file_path, version, expiration_date,
1952
1957
1953
1958
if roleinfo and 'rsa_acc' in roleinfo :
1954
1959
rsa_acc = roleinfo ['rsa_acc' ]
1955
- return tuf . formats .build_dict_conforming_to_schema (
1956
- tuf . formats .TIMESTAMP_SCHEMA ,
1960
+ return formats .build_dict_conforming_to_schema (
1961
+ formats .TIMESTAMP_SCHEMA ,
1957
1962
version = version ,
1958
1963
expires = expiration_date ,
1959
1964
meta = snapshot_fileinfo ,
0 commit comments