Fix removing temp file after unzip

This commit is contained in:
2022-04-24 23:05:37 +03:00
parent faa9400ffb
commit 17632f3215

View File

@@ -148,9 +148,11 @@ class FLDownloader(BaseDownloader):
await temp_file.seek(0) await temp_file.seek(0)
async def _unzip(self, response: httpx.Response) -> Optional[str]: async def _unzip(self, response: httpx.Response) -> Optional[str]:
async with asynctempfile.NamedTemporaryFile(delete=False) as temp_file: async with asynctempfile.NamedTemporaryFile(delete=True) as temp_file:
await self._write_response_content_to_ntf(temp_file, response) await self._write_response_content_to_ntf(temp_file, response)
await temp_file.flush()
return await asyncio.get_event_loop().run_in_executor( return await asyncio.get_event_loop().run_in_executor(
process_pool_executor, unzip, temp_file.name, "fb2" process_pool_executor, unzip, temp_file.name, "fb2"
) )