Repository navigation
fix(scanner): keep locked audiobook metadata through rescans - #3171
Conversation
When an audiobook's files changed, the rescan wrote the tag title, year, genres and publisher over the item even if an admin had locked those fields, so a corrected title reverted on the next scan. Skip locked fields when applying tags, as metadata refreshes already do.
|
Warning Review limit reachedThis review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry. Next included review available in 24 minutes. View limit details
Comment |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
The change is visible: the scanner now preserves locked audiobook metadata in item responses. The API excerpt covers the title only; please add before-and-after excerpts for the same item/request showing the changed locked-field behavior for each of these effects:
Please redact any private library details from the public API excerpt. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
The Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
Reviewed Fit: 10/10 · Readiness: 9/10 — ready I found no introduced defects. This fixes the loss of admin-locked metadata in the existing scanner path. The rescan loads the stored locks before applying tags, and the four lock IDs and field groupings match metadata refresh behavior. Verification
Validated features The refreshed board has no recorded passed cases. #1255 C2 covers edit persistence through rescan and is still Not run. Compatibility and manual Apple, Android and Jellyfin clients receive the corrected values through existing catalog fields; no client or API contract change is needed. The metadata and beta audiobook manual pages need no update for honoring existing locks. Review scope Three Codex finders, a validation/final sweep, and one independent Claude round checked the diff, callers, persistence, contracts and lock semantics. Claude's concern about mirrored constants was checked against the stored IDs and existing catalog precedent; it does not justify a new constants-only test. Its evidence concern relied on the older bot comment: the current PR body includes excerpts for all affected fields. Complete lock coverage remains separate work: a locked empty overview can still be filled, and an admin edit committed between the scanner's read and upsert can still lose its values. Both paths predate this PR. Author and narrator credits are explicitly excluded from this fix. Note AI-generated review by gpt-6.1-sol in T3 Code using the Codex provider. Independent source review: claude-opus-5-5 through T3 Code's Claude provider, one round at high effort. Tools: GitHub CLI and local Go test harnesses. No human acceptance validation is claimed. |
Problem
Related issue: #1253
Validation tasks: changes #1255 C2
An admin's correction to an audiobook doesn't last. When the book's files change, the rescan writes the file's tag title, year, genres and publisher over the item, even when an admin locked those fields. In testing, a locked title "Small Apples (Edited)" went back to "Small Apples" each time the file was touched. Metadata refreshes already honour locks; the audiobook rescan didn't.
The rescan now skips locked fields.
Approach
applyBookToMediaItem, which copies tag values onto the item for new books and changed-book rescans, checkslocked_fieldsfor the title, release dates (year and release date), genres and studios. The scanner can't importmetadata.MetadataField(metadataimportsscanner), so the four values are mirrored as constants; they are stored inmedia_items.locked_fieldsand can't change without a data migration.Author and narrator credits are written separately and still follow the tags. The web admin has no audiobook editor yet (#3162), so locks are set through
PATCH /api/v2/admin/items/{id}/metadatafor now.Validation
go test ./internal/scanner/...,make lint-changed: pass.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3171/
API excerpts from
GET /api/v2/catalog/items/{id}(native API) for the same test book, on the base commite6df1d8edand on this branch. An admin set and locked title, year/release date, genres and publisher throughPATCH /api/v2/admin/items/{id}/metadata; the book's file was then touched and the library rescanned. The file's tags say 2021, Fantasy and Fixture Press.e6df1d8ed)The Chaptered Clockwork(reverted)The Chaptered Clockwork (Edited)2021(reverted)19991999-05-011999-05-01["Edited Genre", "Fantasy"](tag genre added back)["Edited Genre"]["Edited Press", "Fixture Press"](tag publisher added back)["Edited Press"]Risks
None identified.
Checklist
AI Disclosure
applyBookToMediaItemfrom its doc comment; fixed, and both reviewers checked it. Opus also noted that a lock on credits isn't honoured on rescan; that stays out of scope here, as noted above.Note
Fix scanner to keep locked audiobook metadata through rescans
applyBookToMediaItemin audiobook_scan.go now checks the locked-field index before applying tag-derived title, year, release date, genres, or studios. The release-dates lock covers both year and release date. Adds table-driven tests in audiobook_test.go covering locked title, release dates, genres, and studios.metadata.MetadataField; if the two lists drift, the wrong field may be skipped or overwritten.Macroscope summarized be6391d.