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
|
|
@ -46,6 +46,14 @@ def get_or_create_asset(
|
|||
)
|
||||
asset = db.execute(stmt).scalar_one_or_none()
|
||||
if asset is not None:
|
||||
# A previously-FAILED shared asset must be re-attempted for the new job about to hold it —
|
||||
# reset it to pending (+clear the error) so the worker actually re-downloads instead of
|
||||
# short-circuiting the new job with the asset's stale error. (Mirrors resume_download; without
|
||||
# this a fresh enqueue of a once-failed (source,format) pair is permanently poisoned, since
|
||||
# errored assets carry no expires_at and GC never clears them.)
|
||||
if asset.status == "error":
|
||||
asset.status = "pending"
|
||||
asset.error = None
|
||||
return asset
|
||||
asset = MediaAsset(
|
||||
source_kind=source_kind,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue