some fixes to downloader.
This commit is contained in:
parent
3c84741e8a
commit
050012a1b2
2 changed files with 18 additions and 13 deletions
|
|
@ -278,15 +278,19 @@ class Download:
|
|||
"""
|
||||
while True:
|
||||
status = await self.loop.run_in_executor(None, self.status_queue.get)
|
||||
if status.get('id') != self.id or len(status) < 2:
|
||||
|
||||
if status is None:
|
||||
return
|
||||
|
||||
if status.get('id') != self.id or len(status) < 2:
|
||||
continue
|
||||
|
||||
if self.debug:
|
||||
LOG.debug(f'Status Update: {self.info._id=} {status=}')
|
||||
|
||||
if isinstance(status, str):
|
||||
asyncio.create_task(self.notifier.updated(self.info))
|
||||
return
|
||||
continue
|
||||
|
||||
self.tmpfilename = status.get('tmpfilename')
|
||||
|
||||
|
|
|
|||
|
|
@ -388,19 +388,20 @@ class DownloadQueue:
|
|||
async def __downloadFile(self, id: str, entry: Download):
|
||||
LOG.info(f'Queuing {id=} - {entry.info.title=} - {entry.info.url=} - {entry.info.folder=}.')
|
||||
|
||||
await entry.start(self.notifier)
|
||||
try:
|
||||
await entry.start(self.notifier)
|
||||
|
||||
if entry.info.status != 'finished':
|
||||
if entry.tmpfilename and os.path.isfile(entry.tmpfilename):
|
||||
try:
|
||||
os.remove(entry.tmpfilename)
|
||||
entry.tmpfilename = None
|
||||
except:
|
||||
pass
|
||||
if entry.info.status != 'finished':
|
||||
if entry.tmpfilename and os.path.isfile(entry.tmpfilename):
|
||||
try:
|
||||
os.remove(entry.tmpfilename)
|
||||
entry.tmpfilename = None
|
||||
except:
|
||||
pass
|
||||
|
||||
entry.info.status = 'error'
|
||||
|
||||
entry.close()
|
||||
entry.info.status = 'error'
|
||||
finally:
|
||||
entry.close()
|
||||
|
||||
if self.queue.exists(key=id):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue