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 <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
root
2026-01-23 11:22:39 +00:00
parent adb43ee371
commit b27c331d1c
+5 -4
View File
@@ -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]