@@ -174,6 +174,9 @@ async def _check(
174174 async def get_response_file (self , hash : str ) -> abc .ResponseFile :
175175 cpath = str (self .path / "download" / hash [:2 ] / hash )
176176 fileinfo = self ._cache_files .get (hash )
177+ file = self ._cache .get (hash )
178+ if file is not None :
179+ return file
177180
178181 if fileinfo is None :
179182 async with self .session .resource (
@@ -204,7 +207,7 @@ async def get_response_file(self, hash: str) -> abc.ResponseFile:
204207 if self .public_endpoint :
205208 async with self .session .client (
206209 "s3" ,
207- endpoint_url = self .endpoint ,
210+ endpoint_url = self .public_endpoint ,
208211 aws_access_key_id = self .access_key ,
209212 aws_secret_access_key = self .secret_key ,
210213 region_name = self .region
@@ -229,10 +232,12 @@ async def get_response_file(self, hash: str) -> abc.ResponseFile:
229232 urlobj .fragment ,
230233 )
231234 )
232- return abc .ResponseFileRemote (
235+ self . _cache [ hash ] = abc .ResponseFileRemote (
233236 url ,
234237 fileinfo .size
235238 )
239+ return self ._cache [hash ]
240+
236241 async with self .session .resource (
237242 "s3" ,
238243 endpoint_url = self .endpoint ,
@@ -245,8 +250,9 @@ async def get_response_file(self, hash: str) -> abc.ResponseFile:
245250 # read data
246251 content = await obj .get ()
247252 size = content ['ContentLength' ]
248- return abc .ResponseFileMemory (
253+ self . _cache [ hash ] = abc .ResponseFileMemory (
249254 await content ['Body' ].read (),
250255 size
251256 )
257+ return self ._cache [hash ]
252258
0 commit comments