From 2b2a2e69f3ca5f06783a04724d136bb4f4854db2 Mon Sep 17 00:00:00 2001 From: xerdream Date: Wed, 20 Aug 2025 08:19:41 +0800 Subject: [PATCH] change some code that may cause errors --- app/ytdl.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/ytdl.py b/app/ytdl.py index 421bda6..bd79b86 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -33,7 +33,7 @@ class DownloadQueueNotifier: class DownloadInfo: def __init__(self, id, title, url, quality, format, folder, custom_name_prefix, error): self.id = id if len(custom_name_prefix) == 0 else f'{custom_name_prefix}.{id}' - self.id = f'{id}.{format}' + self.id = f'{self.id}.{format}' self.title = title if len(custom_name_prefix) == 0 else f'{custom_name_prefix}.{title}' self.url = url self.quality = quality @@ -205,18 +205,21 @@ class Download: self.info.filename = filename def delete_tmpfile(self): - if not self.tmpfilename: + if not self.tmpfilename or not self.download_dir: return + if not os.path.isdir(self.download_dir): + return + tmpfilename = self.tmpfilename.rsplit('.')[0] def is_tmpfile(filename): return filename.startswith(tmpfilename) - tmpfiles = filter(is_tmpfile ,os.listdir(self.download_dir)) try: + tmpfiles = filter(is_tmpfile, os.listdir(self.download_dir)) for tmpfile in tmpfiles: - os.remove(tmpfile) - except: - pass + os.remove(os.path.join(self.download_dir, tmpfile)) + except Exception as e: + log.warning(f"Error deleting temporary files: {e}") class PersistentQueue: def __init__(self, path):