@@ -56,31 +56,38 @@ def download(self, force=False):
5656 (self .object , self .local_path , self .object_sig , self .local_sig_path ),
5757 (self .metadata_file , self .local_metadata_path , self .metadata_sig_file , self .local_metadata_sig_path ),
5858 ]
59+ skip = False
5960 for (object , local_file , sig_object , local_sig_file ) in files :
6061 if force or not os .path .exists (local_file ):
62+ # First we try to download signature file, which may or may not be available
63+ # and may be optional or required.
64+ try :
65+ self .s3 .download_file (self .bucket , sig_object , local_sig_file )
66+ except :
67+ if self .config ['signatures' ].getboolean ('signatures_required' , True ):
68+ logging .error (
69+ f'Failed to download signature file { sig_object } for { object } from { self .bucket } to { local_sig_file } .'
70+ )
71+ skip = True
72+ break
73+ else :
74+ logging .warning (
75+ f'Failed to download signature file { sig_object } for { object } from { self .bucket } to { local_sig_file } . ' +
76+ 'Ignoring this, because signatures are not required with the current configuration.'
77+ )
78+ # Npw we download the file itself.
6179 try :
6280 self .s3 .download_file (self .bucket , object , local_file )
63- # Also try to download the corresponding signature file; they may be optional.
64- try :
65- self .s3 .download_file (self .bucket , sig_object , local_sig_file )
66- except :
67- if config ['signatures' ].getboolean ('signatures_required' , True ):
68- logging .error (
69- f'Failed to download signature file { sig_object } for { object } from { self .bucket } to { local_sig_file } .'
70- )
71- else :
72- logging .warning (
73- f'Failed to download signature file { sig_object } for { object } from { self .bucket } to { local_sig_file } .' +
74- 'Ignoring this, because signatures are not required with the current configuration.'
75- )
7681 except :
7782 logging .error (
7883 f'Failed to download { object } from { self .bucket } to { local_file } .'
7984 )
80- # If either the tarball itself or its metadata cannot be downloaded, set both to None
81- # to make sure that this tarball is completely ignored/skipped.
82- self .local_path = None
83- self .local_metadata_path = None
85+ skip = True
86+ break
87+ # If any required download failed, make sure to skip this tarball completely.
88+ if skip :
89+ self .local_path = None
90+ self .local_metadata_path = None
8491
8592 def find_state (self ):
8693 """Find the state of this tarball by searching through the state directories in the git repository."""
0 commit comments