Async Download to Library with progress; Download to client

Backend:
- DownloadTask model + background thread runner: streams the file with
  progress (%, bytes, speed) and a cancel flag, then indexes it, names it
  J-<id>.<ext> and applies the e621 metadata
- DownloadTaskViewSet (create/retrieve/cancel) replaces the synchronous
  endpoint; the status footer's worker counts now reflect download jobs
- Client download proxy (/api/online/file/) streams an e621 original to
  the browser with Content-Disposition: attachment, restricted to the
  configured e621 CDN hosts so it cannot be used as an open proxy

Frontend:
- Online detail: progress bar with percentage, transferred size, speed
  and cancel while downloading; success links to the new J-ID
- New 'Download to client' button available to everyone (guests too)
This commit is contained in:
2026-09-17 12:06:15 -05:00
parent bf00cf36a2
commit 6962e483fc
11 changed files with 509 additions and 63 deletions
+9 -4
View File
@@ -9,11 +9,16 @@ from .system_info import get_os_info
def _worker_counts():
"""Active/queued background jobs.
"""Active/queued background jobs (download tasks for now)."""
from apps.library.models import DownloadTask
No task pipeline exists yet, so this reports honest zeros for now.
"""
return {"active": 0, "queued": 0}
active = DownloadTask.objects.filter(
status=DownloadTask.STATUS_DOWNLOADING
).count()
queued = DownloadTask.objects.filter(
status=DownloadTask.STATUS_PENDING
).count()
return {"active": active, "queued": queued}
class StatusView(APIView):