Conversation
|
@bbutlerau |
Embedding ComicInfo.xml rewrites the archive through a temp file created with tempfile.mkstemp, which is always 0600. The rewritten archive then replaced the original, so a file that a media server could read before a Mass Convert or metadata embed was owner-only afterwards. Imports that write ComicInfo while moving a file into the library had the same result: the library copy came out 0600 whatever the source file allowed. Copy the permission bits from the file being replaced (in-place embed) or from the source file (materialize), which is what a plain move or copy would have preserved. The chmod is best effort so mounts that reject it do not fail the rewrite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E9gUFQEryh4gDJRKvjNUZM
Restoring the bits stays best effort, so filesystems that reject chmod still complete the rewrite, but the failure is now logged as a warning naming the archive, so an owner-only file can be traced back to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E9gUFQEryh4gDJRKvjNUZM
9f00830 to
90683b7
Compare
|
Thanks for the review. Both points are done:
The change is in a separate commit on top (90683b7) to make it easier to review. |
Summary
Embedding ComicInfo.xml rewrites the archive through a temp file created with
tempfile.mkstemp, which is always0600. The temp file then replaces the original, so the permission bits the file had before are lost:embed_comicinfo_in_cbz): a library file that was0644or0666comes out0600.materialize_cbz_with_comicinfo): the library copy is0600whatever the source file allowed.For anyone running a reader as a different user (Komga, Kavita and so on), those files become unreadable. With Library Permission Management enabled the import path corrects it afterwards, but it is off by default and the utility path does not apply it. On my install a Mass Convert over 24 files left 7 of them owner-only; the ones that went through a caller-supplied temp path kept sane modes, the
mkstempones did not.Related Issues
None filed. Loosely related to #129 and #132 in that it adds a
chmod, so it is written to be best effort (see below).Changes
_copy_permission_bits()inutilities/comicinfo.pyand call it just before the temp file replaces the target:chmodis wrapped incontextlib.suppress(OSError), so mounts that reject it (some SMB/CIFS shares) do not fail the rewrite.contextlibandosare now module-level imports rather than imported inside the twofinallyblocks.Not changed: direct-download artifacts are deliberately
0600in quarantine, and this PR preserves the source mode, so those still arrive0600unless Library Permission Management is on. That seems worth its own discussion.Checklist
tests/unit/test_comicinfo_embed.py,tests/utilities/test_comicinfo.py,test_archive_subprocess.py,test_mass_convert_pipeline.py,tests/unit/test_library_comicinfo.py,test_issue_import_service.py,test_import_file_registration_adapters.py). The new tests fail ondevelopwithout the change.ruff check src/ tests/)mypy --strict src/pullbox/utilities/comicinfo.py). A full-tree run in my environment reports errors on untoucheddeveloptoo, so I am relying on CI for the full check.ruff format --check src/ tests/)CHANGELOG.mdupdated: left for release prep, per the contributing guideScreenshots
No UI changes.
🤖 Generated with Claude Code