From 097858e24935ddc9bb0b2d5aa4e220f30f19511f Mon Sep 17 00:00:00 2001 From: Zahar Celac Date: Thu, 25 Feb 2021 20:35:18 -0500 Subject: [PATCH] fix bug that can delete all files from your download dir If for any reason a task has empty filename in database (eg. the url you added cannot be reached) and you try to delete this task with 'remove data' option all your files in download dir will be deleted. --- youtube_dl_webui/db.py | 2 +- youtube_dl_webui/task.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl_webui/db.py b/youtube_dl_webui/db.py index 080986c..0db74ae 100644 --- a/youtube_dl_webui/db.py +++ b/youtube_dl_webui/db.py @@ -186,7 +186,7 @@ def delete_task(self, tid): if row is None: raise TaskInexistenceError('') - dl_file = row['filename'] + dl_file = row['filename'] if len(row['filename']) > 0 else None self.db.execute('DELETE FROM task_status WHERE tid=(?)', (tid, )) self.db.execute('DELETE FROM task_info WHERE tid=(?)', (tid, )) diff --git a/youtube_dl_webui/task.py b/youtube_dl_webui/task.py index 6329054..47e41db 100644 --- a/youtube_dl_webui/task.py +++ b/youtube_dl_webui/task.py @@ -211,7 +211,7 @@ def delete_task(self, tid, del_file=False): except TaskInexistenceError as e: raise TaskInexistenceError(e.msg) - if del_file and dl_file is not None: + if del_file and dl_file is not None and len(dl_file) > 0: file_wo_ext, ext = dl_file, None while ext != '': file_wo_ext, ext = os.path.splitext(file_wo_ext)