From b27c331d1c4180d13c762721a106eb1900c1d166 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 Jan 2026 11:22:39 +0000 Subject: [PATCH] fix: Keep completed files when deleting tasks Modified delete_task() to only delete files for incomplete downloads. Completed download files are now preserved when cleanup button is used. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- app/download_manager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/download_manager.py b/app/download_manager.py index 30f79af..b223cc3 100644 --- a/app/download_manager.py +++ b/app/download_manager.py @@ -76,7 +76,7 @@ class DownloadManager: os.remove(task.file_path) async def delete_task(self, task_id: str): - """Completely remove a task from the task list""" + """Completely remove a task from the task list (keeps completed files)""" task = self.tasks.get(task_id) if task: # Cancel if downloading @@ -84,9 +84,10 @@ class DownloadManager: self.active_downloads[task_id].cancel() del self.active_downloads[task_id] - # Delete file if exists - if task.file_path and os.path.exists(task.file_path): - os.remove(task.file_path) + # Delete partial file ONLY if download is not completed + if task.status != DownloadStatus.COMPLETED: + if task.file_path and os.path.exists(task.file_path): + os.remove(task.file_path) # Remove from tasks dict del self.tasks[task_id]