@@ -1370,7 +1370,7 @@ def verify_target_file(target_file_object):
1370
1370
target_filepath = os .path .join (dirname , target_digest + '.' + basename )
1371
1371
1372
1372
return self ._get_file (target_filepath , verify_target_file ,
1373
- 'target' , file_length , download_safely = True )
1373
+ 'target' , file_length )
1374
1374
1375
1375
1376
1376
@@ -1654,8 +1654,7 @@ def _get_metadata_file(self, metadata_role, remote_filename,
1654
1654
1655
1655
1656
1656
1657
- def _get_file (self , filepath , verify_file_function , file_type , file_length ,
1658
- download_safely = True ):
1657
+ def _get_file (self , filepath , verify_file_function , file_type , file_length ):
1659
1658
"""
1660
1659
<Purpose>
1661
1660
Non-public method that tries downloading, up to a certain length, a
@@ -1682,9 +1681,6 @@ def _get_file(self, filepath, verify_file_function, file_type, file_length,
1682
1681
The expected length, or upper bound, of the target or metadata file to
1683
1682
be downloaded.
1684
1683
1685
- download_safely:
1686
- A boolean switch to toggle safe or unsafe download of the file.
1687
-
1688
1684
<Exceptions>
1689
1685
tuf.exceptions.NoWorkingMirrorError:
1690
1686
The metadata could not be fetched. This is raised only when all known
@@ -1708,15 +1704,9 @@ def _get_file(self, filepath, verify_file_function, file_type, file_length,
1708
1704
1709
1705
for file_mirror in file_mirrors :
1710
1706
try :
1711
- # TODO: Instead of the more fragile 'download_safely' switch, unroll
1712
- # the function into two separate ones: one for "safe" download, and the
1713
- # other one for "unsafe" download? This should induce safer and more
1714
- # readable code.
1715
- if download_safely :
1716
- file_object = tuf .download .safe_download (file_mirror , file_length )
1717
-
1718
- else :
1719
- file_object = tuf .download .unsafe_download (file_mirror , file_length )
1707
+ # Eensure the length of the downloaded file matches 'file_length'
1708
+ # exactly.
1709
+ file_object = tuf .download .safe_download (file_mirror , file_length )
1720
1710
1721
1711
# Verify 'file_object' according to the callable function.
1722
1712
# 'file_object' is also verified if decompressed above (i.e., the
0 commit comments