Conversation
Wrap the playlist file read in _update_playlist_file in a with block so the handle is not left open, and close the Database in a finally in the CLI so it is closed on both success and error paths. The cli.py diff is mostly re-indentation of the code moved under the new try block; review with git diff -w.
|
[Account-2 upstream-readiness review — 2026-09-20 · read-only adversarial verification pass; nothing in this PR, repo, or workspace was modified] Verdict: READY-WITH-NOTES for upstream filing (one stale number to fix first). Mechanics verified at head PRE-SHIP (body-only):
EVALUATE (high — filing mechanics): open upstream PRs glomatico#345 (hunk @ :148) and glomatico#335 (@ :285) touch cli.py inside this PR's re-indented region — either filing order needs a rebase; downloader.py has no upstream overlap; glomatico#341 sits outside the region. Decision question for the owner: fix the count + two phrasings at pickup? (implement-it / evaluate — nothing pre-selected.) |
60-second summary
Two leaked resources are now closed: the playlist M3U8 file handle and the download-database connection. Verify with
git diff -w 478c3f2 e5c44fe(semantic change is +4/−4 lines; the raw diff is mostly re-indentation ofmain()moving under a newtry). Risk is minimal; rollback isgit revert e5c44fe.What
_update_playlist_filereads the playlist file inside awithblock, and the CLI closes theDatabasein afinallyafter all uses (success or error).Why
The playlist read at
gamdl/downloader/downloader.py:119-123left the file handle to the garbage collector, andDatabasecreated atgamdl/cli/cli.py:130-135was never closed —Database.close(gamdl/cli/database.py:44-45) had no callers. Evidence and discussion: #2.The change
gamdl/downloader/downloader.py:withblock around the playlist-file read (same data, handle now released deterministically).gamdl/cli/cli.py: everything afterDatabasecreation wrapped intry/finallywithif database: database.close(); thedatabasecan beNoneon early config errors, and the close sits after the lastdatabase.add/flat_filteruse.Verification
python3 -m py_compileon both touched files: clean; both modules import in the project venv.Database(temp sqlite, no network/credentials): add/get roundtrip, connection unusable afterclose()(sqlite3.ProgrammingError), double-close safe,flat_filterbehavior, and the committedwith-read shape — 5/5 PASS. Probe and output preserved atscratch-resource-hygiene/in the workspace (the first probe run was not kept; it was re-run and saved — flagged by the test-honesty review, see below).Reviews
Noneguard, and no double-close verified; one theoretical note (a raisingclose()could mask an in-flight exception) accepted as non-blocking.Attribution
This PR was produced with AI assistance under the direction of @JavaGT:
Every change was cross-reviewed and the final diff verified against the described behavior. Happy to adjust or close any part of this — tell me what doesn't fit the project's direction.