From 567e9d473b2c65c3e85be76ab78a0fddb7d2b0a3 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 11 Oct 2021 15:26:31 +0700 Subject: [PATCH] fix killing task with missing task id --- tubearchivist/home/tasks.py | 4 +++- tubearchivist/home/views.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index fa8562e..7346304 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -138,7 +138,9 @@ def run_restore_backup(): def kill_dl(task_id): """kill download worker task by ID""" - app.control.revoke(task_id, terminate=True) + if task_id: + app.control.revoke(task_id, terminate=True) + _ = RedisArchivist().del_message("dl_queue_id") RedisQueue("dl_queue").clear() diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index eef969f..c05545b 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -588,7 +588,10 @@ class PostData: RedisQueue("dl_queue").clear() elif to_execute == "kill": task_id = RedisArchivist().get_message("dl_queue_id") - print("brutally killing " + task_id) + if not task_id["status"]: + task_id = False + else: + print("brutally killing " + task_id) kill_dl(task_id) return {"success": True}