From 3a8bf001dd66d7176908142936799b86099a4574 Mon Sep 17 00:00:00 2001 From: guahki <85439599+guahki@users.noreply.github.com> Date: Thu, 22 Jun 2023 22:36:24 +0200 Subject: [PATCH] Fix issues with deleting files with DELETE_FILE_ON_TRASHCAN Not being able to delete the file should not stop the clearance from the download list. One error I encountered, is when failed downloads have no dl.info.filename attribute. It was impossible to delete these entries from the "Completed" section. --- app/ytdl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/ytdl.py b/app/ytdl.py index 2c52f72..2f5f560 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -300,7 +300,10 @@ class DownloadQueue: continue if self.config.DELETE_FILE_ON_TRASHCAN: dl = self.done.get(id) - os.remove(os.path.join(dl.download_dir, dl.info.filename)) + try: + os.remove(os.path.join(dl.download_dir, dl.info.filename)) + except Exception as e: + log.warn(f'deleting file for download {id} failed with error message {e}') self.done.delete(id) await self.notifier.cleared(id) return {'status': 'ok'}