Fix FileNotFound when unzip

This commit is contained in:
2022-04-24 23:25:17 +03:00
parent 17632f3215
commit 0ef8d8f961

View File

@@ -153,9 +153,12 @@ class FLDownloader(BaseDownloader):
await temp_file.flush() await temp_file.flush()
try:
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"
) )
except FileNotFoundError:
return None
async def _download_with_converting( async def _download_with_converting(
self, self,
@@ -185,6 +188,9 @@ class FLDownloader(BaseDownloader):
await response.aclose() await response.aclose()
await client.aclose() await client.aclose()
if filename_to_convert is None:
raise ValueError
form = {"format": self.file_type} form = {"format": self.file_type}
files = {"file": open(filename_to_convert, "rb")} files = {"file": open(filename_to_convert, "rb")}
@@ -241,6 +247,9 @@ class FLDownloader(BaseDownloader):
await response.aclose() await response.aclose()
await client.aclose() await client.aclose()
if temp_filename is None:
return None
if self.need_zip: if self.need_zip:
content_filename = await asyncio.get_event_loop().run_in_executor( content_filename = await asyncio.get_event_loop().run_in_executor(
process_pool_executor, zip, await self.get_filename(), temp_filename process_pool_executor, zip, await self.get_filename(), temp_filename