@@ -97,7 +97,7 @@ def _copy(self, from_info, to_info, s3=None):
9797
9898 source = {'Bucket' : from_info ['bucket' ],
9999 'Key' : from_info ['key' ]}
100- self .s3 .Bucket ( to_info ['bucket' ]). copy ( source , to_info ['key' ])
100+ self .s3 .copy ( source , to_info ['bucket' ], to_info ['key' ])
101101
102102 def save (self , path_info ):
103103 if path_info ['scheme' ] != 's3' :
@@ -139,12 +139,7 @@ def md5s_to_path_infos(self, md5s):
139139 'bucket' : self .bucket ,
140140 'key' : posixpath .join (self .prefix , md5 [0 :2 ], md5 [2 :])} for md5 in md5s ]
141141
142- def exists (self , path_infos ):
143- # NOTE: We mostly use exists() method when filtering a bulk of cache
144- # files to decide if we need to download/upload them and in s3
145- # list_objects_v2() is much-much faster than trying to check keys
146- # one-by-one.
147- ret = []
142+ def _all_keys (self ):
148143 s3 = self .s3
149144
150145 keys = []
@@ -165,6 +160,17 @@ def exists(self, path_infos):
165160
166161 kwargs ['ContinuationToken' ] = token
167162
163+ return keys
164+
165+ def exists (self , path_infos ):
166+ # NOTE: We mostly use exists() method when filtering a bulk of cache
167+ # files to decide if we need to download/upload them and in s3
168+ # list_objects_v2() is much-much faster than trying to check keys
169+ # one-by-one.
170+ ret = []
171+
172+ keys = self ._all_keys ()
173+
168174 for path_info in path_infos :
169175 exists = False
170176 if path_info ['key' ] in keys :
@@ -253,8 +259,8 @@ def _path_to_etag(self, path):
253259 return posixpath .dirname (relpath ) + posixpath .basename (relpath )
254260
255261 def _all (self ):
256- objects = self .s3 . Bucket ( self . bucket ). objects . filter ( Prefix = self . prefix )
257- return [self ._path_to_etag (obj . key ) for obj in objects ]
262+ keys = self ._all_keys ( )
263+ return [self ._path_to_etag (key ) for key in keys ]
258264
259265 def gc (self , checksum_infos ):
260266 used_etags = [info [self .PARAM_ETAG ] for info in checksum_infos ['s3' ]]
0 commit comments