mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-28 19:06:19 -05:00
* Persist finalize_download mutations; isolate child-download enqueue A channel/RSS Download could get stuck permanently "pending". Root cause: the phase-split dispatch in signal_download_download passes the Download loaded in an already-closed session to finalize_download, so it is DETACHED. ChannelDownloader.finalize_download sets `download.sub_downloader = 'video'` (and info_json/collection_id) on that detached object, so the write never reaches the DB. The status block then re-queries the Download fresh, reads sub_downloader=None, and calls create_downloads(downloader_name=None) -> `InvalidDownload: Cannot find downloader with name None`. That exception was raised inside the status-commit transaction (outside the inner try), so it (a) rolled back the parent's complete(), reverting it to the `pending` set by started(), and (b) was swallowed by the outer bare `except Exception`, which only logs. Result: the parent never failed, never completed — it sat `pending` forever, re-crashing the same way on every restart. Fixes: - finalize_download is now given a Download re-loaded in (attached to) its own session, so its mutations persist. - Child-download creation moves to its own transaction after the parent's status is committed. A failure there is logged and cannot roll back or strand the parent. The existing test harness reuses one shared DB session for every get_db_session call, so detached-object and rollback bugs never reproduced under it (which is why this shipped). Add `production_like_sessions` to conftest.py — a context manager handing out a fresh Session per call, like production — and two regression tests that fail without the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Re-attach Download in prepare_download too (consistency) prepare_download receives the same detached Download as finalize_download did, so VideoDownloader.prepare_download's writes to the row (destination/tag_names) are not reliably persisted. Re-load the Download attached to the prepare session, mirroring the finalize fix, so the row's metadata is accurate. Unlike sub_downloader (which the status block re-reads and feeds to create_downloads), nothing downstream re-reads these values, so this is a consistency/cosmetic improvement, not a functional bug — and it cannot be made to fail in a test (the loaded Download's session outlives the worker), so no dedicated test is added. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Log (not swallow) session-close failures in production_like_sessions Addresses Greptile review: surface a failed session.close() at debug level instead of silently passing. engine.dispose() still does the authoritative cleanup, so the close failure remains non-fatal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| collections | ||
| files | ||
| scripts | ||
| static/extensions | ||
| test | ||
| __init__.py | ||
| api_utils.py | ||
| captions.py | ||
| cmd.py | ||
| common.py | ||
| config_api.py | ||
| config_schema.py | ||
| conftest.py | ||
| contexts.py | ||
| dates.py | ||
| db.py | ||
| downloader.py | ||
| errors.py | ||
| events.py | ||
| flags.py | ||
| lang.py | ||
| log_levels.py | ||
| logging_extra.py | ||
| media_path.py | ||
| roland@learningselfreliance.com.gpg | ||
| root_api.py | ||
| schema.py | ||
| scrape_downloader.py | ||
| switches.py | ||
| tags.py | ||
| test_media_path.py | ||
| upgrade.py | ||
| vars.py | ||
| version.py | ||
| version.txt | ||