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:
@@ -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,7 +84,8 @@ class DownloadManager:
|
||||
self.active_downloads[task_id].cancel()
|
||||
del self.active_downloads[task_id]
|
||||
|
||||
# Delete file if exists
|
||||
# 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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user