@@ -204,7 +204,9 @@ async def _call_s3(self, method, *akwarglist, **kwargs):
204204 ** kwargs )
205205 for i in range (self .retries ):
206206 try :
207- return await method (** additional_kwargs )
207+ out = await method (** additional_kwargs )
208+ locals ().pop ("err" , None ) # break cycle following retry
209+ return out
208210 except S3_RETRYABLE_ERRORS as e :
209211 logger .debug ("Retryable error: %s" % e )
210212 err = e
@@ -484,7 +486,7 @@ async def _find(self, path, maxdepth=None, withdirs=None, detail=False):
484486 async def _mkdir (self , path , acl = "" , create_parents = True , ** kwargs ):
485487 path = self ._strip_protocol (path ).rstrip ('/' )
486488 bucket , key , _ = self .split_path (path )
487- if not key or (create_parents and not self .exists (bucket )):
489+ if not key or (create_parents and not await self ._exists (bucket )):
488490 if acl and acl not in buck_acls :
489491 raise ValueError ('ACL not in %s' , buck_acls )
490492 try :
@@ -595,6 +597,12 @@ async def _exists(self, path):
595597 elif self .dircache .get (bucket , False ):
596598 return True
597599 else :
600+ try :
601+ if self ._ls_from_cache (bucket ):
602+ return True
603+ except FileNotFoundError :
604+ # might still be a bucket we can access but don't own
605+ pass
598606 try :
599607 await self .s3 .list_objects_v2 (MaxKeys = 1 , Bucket = bucket , ** self .req_kw )
600608 return True
0 commit comments