fix(downloads): repair 5 confirmed backend bugs (B1-B5)
- B1 (sticky errored asset): get_or_create_asset now resets a reused status=='error' asset back to 'pending' (+clears the error), so a fresh enqueue/edit of a once-failed (source,format) pair actually re-downloads instead of the worker short-circuiting the new job with the stale error. Errored assets carry no expires_at, so without this the pair was permanently poisoned for all users until someone hit resume. - B2 (ref_count leak): _release_asset counts 'error' as a holding state, so deleting an errored job decrements the ref_count that enqueue always incremented (the worker never decrements on failure). Errored rows are deliberately NOT deleted here — a concurrent B1 reuse could otherwise be lost-updated + FK-nulled; the row is fileless and harmless. - B3: admin storage dashboard reads sysconfig.get_int(db,'download_total_max_bytes') (the admin-editable DB value GC enforces) instead of the raw env default. - B4: the single-trim branch of normalize_edit_spec guards its float() coercion like the crop/segments branches — a malformed trim now yields a 400, not an unhandled 500. - B5: formats.normalize guards int(max_height) → falls back to "best" instead of 500. Reviewed (race in an earlier B2 draft caught + fixed); localdev boots, B4/B5 unit-verified.
This commit is contained in:
parent
bf8d4b94a0
commit
7a6f351e64
4 changed files with 38 additions and 11 deletions
|
|
@ -62,7 +62,12 @@ def normalize(spec: dict) -> dict:
|
|||
if s["mode"] not in ("av", "v", "a"):
|
||||
s["mode"] = "av"
|
||||
if s["max_height"] is not None:
|
||||
s["max_height"] = int(s["max_height"])
|
||||
# A malformed max_height (non-numeric inline spec / stored profile) falls back to "best"
|
||||
# rather than raising an unhandled 500 at enqueue.
|
||||
try:
|
||||
s["max_height"] = int(s["max_height"])
|
||||
except (TypeError, ValueError):
|
||||
s["max_height"] = None
|
||||
for b in ("embed_subs", "embed_chapters", "embed_thumbnail", "sponsorblock"):
|
||||
s[b] = bool(s[b])
|
||||
# Audio-only files can't embed subtitles/thumbnails as video; keep the flags meaningful.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue