@@ -1315,7 +1315,8 @@ def _soft_check_file_length(self, file_object, trusted_file_length):
13151315
13161316
13171317
1318- def _get_target_file (self , target_filepath , file_length , file_hashes ):
1318+ def _get_target_file (self , target_filepath , file_length , file_hashes ,
1319+ prefix_filename_with_hash ):
13191320 """
13201321 <Purpose>
13211322 Non-public method that safely (i.e., the file length and hash are
@@ -1334,6 +1335,13 @@ def _get_target_file(self, target_filepath, file_length, file_hashes):
13341335 file_hashes:
13351336 The expected hashes of the target file.
13361337
1338+ prefix_filename_with_hash:
1339+ Whether to prefix the targets file names with their hash when using
1340+ consistent snapshot.
1341+ This should be set to False when the served target filenames are not
1342+ prefixed with hashes (in this case the server uses other means
1343+ to ensure snapshot consistency).
1344+
13371345 <Exceptions>
13381346 tuf.exceptions.NoWorkingMirrorError:
13391347 The target could not be fetched. This is raised only when all known
@@ -1357,7 +1365,7 @@ def verify_target_file(target_file_object):
13571365 self ._hard_check_file_length (target_file_object , file_length )
13581366 self ._check_hashes (target_file_object , file_hashes )
13591367
1360- if self .consistent_snapshot :
1368+ if self .consistent_snapshot and prefix_filename_with_hash :
13611369 # Note: values() does not return a list in Python 3. Use list()
13621370 # on values() for Python 2+3 compatibility.
13631371 target_digest = list (file_hashes .values ()).pop ()
@@ -3217,7 +3225,8 @@ def updated_targets(self, targets, destination_directory):
32173225
32183226
32193227
3220- def download_target (self , target , destination_directory ):
3228+ def download_target (self , target , destination_directory ,
3229+ prefix_filename_with_hash = True ):
32213230 """
32223231 <Purpose>
32233232 Download 'target' and verify it is trusted.
@@ -3234,6 +3243,14 @@ def download_target(self, target, destination_directory):
32343243 destination_directory:
32353244 The directory to save the downloaded target file.
32363245
3246+ prefix_filename_with_hash:
3247+ Whether to prefix the targets file names with their hash when using
3248+ consistent snapshot.
3249+ This should be set to False when the served target filenames are not
3250+ prefixed with hashes (in this case the server uses other means
3251+ to ensure snapshot consistency).
3252+ Default is True.
3253+
32373254 <Exceptions>
32383255 securesystemslib.exceptions.FormatError:
32393256 If 'target' is not properly formatted.
@@ -3268,7 +3285,7 @@ def download_target(self, target, destination_directory):
32683285 # '_get_target_file()' checks every mirror and returns the first target
32693286 # that passes verification.
32703287 target_file_object = self ._get_target_file (target_filepath , trusted_length ,
3271- trusted_hashes )
3288+ trusted_hashes , prefix_filename_with_hash )
32723289
32733290 # We acquired a target file object from a mirror. Move the file into place
32743291 # (i.e., locally to 'destination_directory'). Note: join() discards
0 commit comments