Skip to content

Add read-only library flag to block tag writes#787

Merged
ajslater merged 3 commits into
developfrom
worktree-read-only-library
Jun 23, 2026
Merged

Add read-only library flag to block tag writes#787
ajslater merged 3 commits into
developfrom
worktree-read-only-library

Conversation

@ajslater

Copy link
Copy Markdown
Owner

What

Adds a read_only boolean flag to libraries. Comics in a read-only library are protected from every archive-mutating operation — Edit Tags and Tag Online — while still importing, polling, generating covers, and tracking bookmarks normally.

Why

Some libraries should never have their comic files modified: shared/curated collections, read-only mounts, or archives the user simply doesn't want touched. Today any admin can write tags into any comic.

How it works

  • Model + migrationLibrary.read_only (BooleanField(db_index=True, default=False)), migration 0045. Editable in the admin Libraries form/table.
  • Single enforcement funnelFilteredComicPksView.resolve_comic_pks (shared by tag-write, online-tag, preflight, tag-by-id) now drops library__read_only=True comics and reports how many were skipped. No read-only comic is ever enqueued for a write, regardless of the UI.
  • Defense in depth — the librarian executors (tag_writer, onlinetag/session_manager) also exclude read-only comics, so a hand-crafted task can't slip through.
  • Mixed selections — a selection spanning several libraries stays editable as long as one comic is writable; only the writable comics are written, and the user is told how many were skipped (confirm dialog + success toast).
  • Button visibility — the metadata payload gains an editable aggregate (true when any selected comic is in a writable library); the Edit Tags / Tag Online entry points hide when it's false. Covers the reader too (same dialog).

Reviewer notes

  • Behavior choice: read-only blocks writes into archive files only; reads/import/covers/bookmarks are unaffected.
  • Mixed-selection UX: writable comics are written and a skipped count is surfaced (chosen over silently dropping).
  • New tests in tests/test_read_only_library.py (7) cover the funnel exclusion, the reported skipped count, the all-read-only rejection, and the metadata editable aggregate (writable / read-only / mixed). Existing tag-write, online-tag, and metadata suites pass unchanged.
  • Includes a small drive-by fix: a pre-existing Property "updateLabel" was accessed during render but is not defined Vue warning in the admin library table (dropped a dead :label binding).

🤖 Generated with Claude Code

ajslater and others added 3 commits June 22, 2026 20:19
Mark a Library read_only to protect its comics from all archive-mutating
operations (Edit Tags + Tag Online). Enforced server-side at the single
resolve_comic_pks funnel and again at the task executors; mixed selections
write only editable comics and report a skipped count. The metadata payload
gains an `editable` aggregate that hides the edit/tag buttons when nothing
in the selection is writable.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The edit dialog bound :label="updateLabel", but updateLabel was never
defined on the component, so Vue warned on every render once a library
row existed. The dialog's label prop already falls back to the table
name, so drop the broken binding.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@ajslater ajslater merged commit 9b17026 into develop Jun 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant