Skip to content

Hygiene: unclosed file handle in _update_playlist_file; Database connection never closed (close() is dead code) #2

Description

@JavaGT

Audit finding (read-only review of gamdl 3.8.5, commit 478c3f2). Cross-checked by two models; both judge it real but low severity.

Lens: reliability / resource hygiene
Suggested grade: Worth exploring

Evidence

  1. gamdl/downloader/downloader.py:119-123 — file handle never closed:
playlist_file_lines = (
    playlist_file_path_obj.open("r", encoding="utf8").readlines()
    if playlist_file_path_obj.exists()
    else []
)
  1. gamdl/cli/cli.py:130-135 — Database(config.database_path, config.overwrite) is created but close() is never called on any exit path; Database.close (gamdl/cli/database.py:44-45) is dead code (verified via repo-wide grep: no caller).

Impact: minor. CPython refcounting closes the readlines() handle promptly, and sqlite3 commits every add(), so no data loss — but explicit cleanup is the correct pattern and costs two one-line changes.

Model verdicts

  • luna (gpt-5.6-luna): real, low. "The database should be closed in a try/finally or context-manager path; durability from commits does not eliminate connection/lock cleanup concerns."
  • grok (grok-4.6): real (sloppy cleanup, not serious leak), low. "with path.open(...). Close the database in a try/finally (or make Database a context manager)."

Fix direction: wrap the readlines() in a with block; call database.close() at the end of main() (try/finally), or make Database a context manager.

Adopt as upstream contribution candidate? (adopt / adapt / reject)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions