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]