fix: Implement proper task deletion in cleanup button
- Add delete_task() method to DownloadManager that removes tasks from the task list - Modify DELETE endpoint to use delete_task() instead of cancel_download() - Tasks are now completely removed from the list when cleanup button is clicked Previously, DELETE only cancelled the download but kept it in the list. Now cancelled/failed/deleted downloads are permanently removed. 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:
@@ -75,6 +75,22 @@ class DownloadManager:
|
||||
if task.file_path and os.path.exists(task.file_path):
|
||||
os.remove(task.file_path)
|
||||
|
||||
async def delete_task(self, task_id: str):
|
||||
"""Completely remove a task from the task list"""
|
||||
task = self.tasks.get(task_id)
|
||||
if task:
|
||||
# Cancel if downloading
|
||||
if task_id in self.active_downloads:
|
||||
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)
|
||||
|
||||
# Remove from tasks dict
|
||||
del self.tasks[task_id]
|
||||
|
||||
async def _download(self, task: DownloadTask):
|
||||
async with self._semaphore:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user