From 83057d9e54c740ee9e6916caf1d4d4e703b359c4 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 2 Feb 2023 10:46:59 +0700 Subject: [PATCH] return files clearded from clear_dl_cache --- tubearchivist/home/src/ta/helper.py | 5 ++++- tubearchivist/home/tasks.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tubearchivist/home/src/ta/helper.py b/tubearchivist/home/src/ta/helper.py index f07dc805..22797905 100644 --- a/tubearchivist/home/src/ta/helper.py +++ b/tubearchivist/home/src/ta/helper.py @@ -122,10 +122,13 @@ def clear_dl_cache(config): """clear leftover files from dl cache""" print("clear download cache") cache_dir = os.path.join(config["application"]["cache_dir"], "download") - for cached in os.listdir(cache_dir): + leftover_files = os.listdir(cache_dir) + for cached in leftover_files: to_delete = os.path.join(cache_dir, cached) os.remove(to_delete) + return len(leftover_files) + def get_mapping(): """read index_mapping.json and get expected mapping and settings""" diff --git a/tubearchivist/home/tasks.py b/tubearchivist/home/tasks.py index c41a7aa5..8cd7d041 100644 --- a/tubearchivist/home/tasks.py +++ b/tubearchivist/home/tasks.py @@ -228,7 +228,7 @@ def kill_dl(task_id): _ = RedisArchivist().del_message("dl_queue_id") RedisQueue(queue_name="dl_queue").clear() - clear_dl_cache(CONFIG) + _ = clear_dl_cache(CONFIG) # notify mess_dict = {