Remove GLOBAL_GID when queue task cancelled

This commit is contained in:
Heroku 2024-11-25 00:21:41 +07:00
parent b2060f1f3b
commit f23ce882ae

View File

@ -60,10 +60,8 @@ class TelegramDownloadHelper:
async def _on_download_error(self, error):
async with global_lock:
try:
if self._id in GLOBAL_GID:
GLOBAL_GID.remove(self._id)
except:
pass
await self._listener.on_download_error(error)
async def _on_download_complete(self):
@ -148,6 +146,9 @@ class TelegramDownloadHelper:
await send_status_message(self._listener.message)
await event.wait()
if self._listener.is_cancelled:
async with global_lock:
if self._id in GLOBAL_GID:
GLOBAL_GID.remove(self._id)
return
await self._on_download_start(gid, add_to_queue)