Skip to content

Commit

Permalink
fix bug that can delete all files from your download dir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zaharcelac committed Feb 26, 2021
1 parent 75d296b commit 097858e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion youtube_dl_webui/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ))
Expand Down
2 changes: 1 addition & 1 deletion youtube_dl_webui/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 097858e

Please sign in to comment.