@@ -148,7 +148,15 @@ async def path_upload_handler(
148148
149149 path_key = os .path .join (key_prefix , path ) if key_prefix else path
150150 file_object : s3 .Object = bucket .Object (path_key )
151- existed = await self .__run_async (self .__file_exists , file_object )
151+ existed = False
152+ try :
153+ existed = await self .__run_async (self .__file_exists , file_object )
154+ except (ClientError , HTTPClientError ) as e :
155+ logger .error (
156+ "Error: file existence check failed due to error: %s" , e
157+ )
158+ failed .append (full_file_path )
159+ return
152160 sha1 = read_sha1 (full_file_path )
153161 (content_type , _ ) = mimetypes .guess_type (full_file_path )
154162 if not content_type :
@@ -262,7 +270,15 @@ async def path_upload_handler(
262270
263271 path_key = os .path .join (key_prefix , path ) if key_prefix else path
264272 file_object : s3 .Object = bucket .Object (path_key )
265- existed = await self .__run_async (self .__file_exists , file_object )
273+ existed = False
274+ try :
275+ existed = await self .__run_async (self .__file_exists , file_object )
276+ except (ClientError , HTTPClientError ) as e :
277+ logger .error (
278+ "Error: file existence check failed due to error: %s" , e
279+ )
280+ failed .append (full_file_path )
281+ return
266282 f_meta = {}
267283 need_overwritten = True
268284 sha1 = read_sha1 (full_file_path )
@@ -367,7 +383,15 @@ async def path_delete_handler(
367383 logger .debug ('(%d/%d) Deleting %s from bucket %s' , index , total , path , bucket_name )
368384 path_key = os .path .join (key_prefix , path ) if key_prefix else path
369385 file_object = bucket .Object (path_key )
370- existed = await self .__run_async (self .__file_exists , file_object )
386+ existed = False
387+ try :
388+ existed = await self .__run_async (self .__file_exists , file_object )
389+ except (ClientError , HTTPClientError ) as e :
390+ logger .error (
391+ "Error: file existence check failed due to error: %s" , e
392+ )
393+ failed .append (full_file_path )
394+ return
371395 if existed :
372396 # NOTE: If we're NOT using the product key to track collisions
373397 # (in the case of metadata), then this prods array will remain
@@ -458,7 +482,15 @@ def delete_manifest(self, product_key: str, target: str, manifest_bucket_name: s
458482
459483 manifest_bucket = self .__get_bucket (manifest_bucket_name )
460484 file_object : s3 .Object = manifest_bucket .Object (path_key )
461- if self .__file_exists (file_object ):
485+ existed = False
486+ try :
487+ existed = self .__file_exists (file_object )
488+ except (ClientError , HTTPClientError ) as e :
489+ logger .error (
490+ "Error: file existence check failed due to error: %s" , e
491+ )
492+ return
493+ if existed :
462494 manifest_bucket .delete_objects (Delete = {"Objects" : [{"Key" : path_key }]})
463495 else :
464496 logger .warning (
@@ -555,8 +587,7 @@ def __file_exists(self, file_object: Object) -> bool:
555587 if isinstance (e , ClientError ) and e .response ["Error" ]["Code" ] == "404" :
556588 return False
557589 else :
558- logger .error ("Error: file existence check failed due "
559- "to error: %s" , e )
590+ raise e
560591
561592 def __get_prod_info (
562593 self , file : str , bucket_name : str
0 commit comments