Fix delete not finding the download: wrong id sent to MeTube's /delete

MeTube's queue/pending/done stores are keyed by the download's URL
(PersistentQueue.put: key = value.info.url), not by the id field a Download
reports over Socket.IO (which is what we stored as metube_job_id and were
sending). Sending the wrong key made MeTube's clear()/cancel() silently
no-op ("requested delete for non-existent download" in its own logs) while
still returning {"status": "ok"} regardless -- confirmed live by curling
/history on the real instance and finding the "deleted" entry still
present, unrelated to the DELETE_FILE_ON_TRASHCAN config fix that came
right before this.

delete_download() now takes the video's canonical youtube_url instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-09-16 20:14:43 +00:00
parent 441a3ef9df
commit 62f8fb746b
3 changed files with 19 additions and 11 deletions

View file

@ -75,11 +75,9 @@ def delete_local_copy(db: Session, video: Video) -> DownloadJob:
job = get_latest_job(db, video.id)
if job is None or job.status != "completed":
raise DeleteNotAllowed("No completed local copy to delete")
if not job.metube_job_id:
raise DeleteNotAllowed("Missing MeTube job id, cannot request deletion")
client = MeTubeClient()
client.delete_download(job.metube_job_id)
client.delete_download(video.youtube_url)
# MeTube's /delete only unlinks the file if it's configured with
# DELETE_FILE_ON_TRASHCAN=true -- otherwise it just drops the entry from