@@ -119,7 +119,7 @@ def _generate_and_write_metadata(rolename, metadata_filename,
119119
120120
121121 elif rolename == 'snapshot' :
122- metadata = generate_snapshot_metadata (metadata_directory ,
122+ metadata , fileinfodict = generate_snapshot_metadata (metadata_directory ,
123123 roleinfo ['version' ], roleinfo ['expires' ],
124124 storage_backend , consistent_snapshot , repository_name ,
125125 use_length = use_snapshot_length , use_hashes = use_snapshot_hashes )
@@ -128,10 +128,10 @@ def _generate_and_write_metadata(rolename, metadata_filename,
128128 root , leaves = _build_rsa_acc (fileinfodict )
129129
130130 # 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 )
132132 timestamp_roleinfo ['rsa_acc' ] = root
133133
134- tuf . roledb .update_roleinfo ('timestamp' , timestamp_roleinfo ,
134+ roledb .update_roleinfo ('timestamp' , timestamp_roleinfo ,
135135 repository_name = repository_name )
136136
137137
@@ -145,7 +145,8 @@ def _generate_and_write_metadata(rolename, metadata_filename,
145145
146146 metadata = generate_timestamp_metadata (snapshot_file_path , roleinfo ['version' ],
147147 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 )
149150
150151 _log_warning_if_expires_soon (TIMESTAMP_FILENAME , roleinfo ['expires' ],
151152 TIMESTAMP_EXPIRES_WARN_SECONDS )
@@ -393,6 +394,8 @@ def _delete_obsolete_metadata(metadata_directory, snapshot_metadata,
393394 for metadata_role in metadata_files :
394395 if metadata_role .endswith ('root.json' ):
395396 continue
397+ if metadata_role .endswith ('-snapshot.json' ):
398+ continue
396399
397400 metadata_path = os .path .join (metadata_directory , metadata_role )
398401
@@ -1697,9 +1700,8 @@ def _write_rsa_proofs(root, leaves, storage_backend, rsa_acc_directory, version)
16971700
16981701 for l in leaves :
16991702 # 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 ,
17031705 leaf_contents = l .contents ,
17041706 rsa_acc_proof = str (l .proof ))
17051707 file_content = _get_written_metadata (file_contents )
@@ -1861,19 +1863,22 @@ def generate_snapshot_metadata(metadata_directory, version, expiration_date,
18611863 # generate_root_metadata, etc. with one function that generates
18621864 # metadata, possibly rolling that upwards into the calling function.
18631865 # 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 (
18651867 formats .SNAPSHOT_SCHEMA ,
18661868 version = version ,
18671869 expires = expiration_date ,
18681870 meta = fileinfodict )
18691871
1872+ return metadata , fileinfodict
1873+
18701874
18711875
18721876
18731877
18741878
18751879def 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 ):
18771882 """
18781883 <Purpose>
18791884 Generate the timestamp metadata object. The 'snapshot.json' file must
@@ -1952,8 +1957,8 @@ def generate_timestamp_metadata(snapshot_file_path, version, expiration_date,
19521957
19531958 if roleinfo and 'rsa_acc' in roleinfo :
19541959 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 ,
19571962 version = version ,
19581963 expires = expiration_date ,
19591964 meta = snapshot_fileinfo ,
0 commit comments