Repository navigation
Conversation
Library ingest ran the filename-based variant pass over audiobook libraries too. It replaced the multipart presentation the audiobook scanner writes, which changed part order for some books and made every multi-file book fail the scanner's unchanged-book check, so each scan re-probed and rewrote it. Skip the pass for audiobook libraries.
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:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…udiobook-variant-finalize # Conflicts: # internal/libraryingest/executor.go
Quick104
left a comment
There was a problem hiding this comment.
Review of 03486ed. Two findings. I'm fixing both in commits on this branch, so there's no need to change anything yourself.
Low: single-file audiobooks keep values from the old variant pass (internal/scanner/audiobook_scan.go, outside this diff)
The description says libraries with rewritten rows repair themselves. That holds for multi-file books, because their rewritten rows fail the skip check. A single-file book is rebuilt only when its presentation_kind is multipart. The old pass could leave multipart_movie or an edition on a single-file book, and those rows still pass the skip check. With the pass gone, nothing clears them.
Trigger: Book {edition-Extended}/Book - Part 1.mp3 scanned on an earlier build. Impact: after upgrading, the file keeps presentation_kind = multipart_movie and edition_key = extended until it changes on disk. The same book scanned fresh has neither. I reproduced this against a migrated PostgreSQL 18 with the real scanner. It's narrow: only {edition-…} tags or a lone Part N file name trigger the parser for audiobooks, and those books behave the same as on main.
Repair: for a single-file book, rebuild when presentation_kind or edition_key is set. The audiobook scanner writes neither for single-file books, so the rebuild runs once and later scans skip the book again.
Earlier builds ran the filename variant pass over audiobook libraries and could leave a presentation kind or an edition on a single-file book. The skip check only rebuilt single-file books marked multipart, so those rows kept the stale values after the pass stopped running there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
No CI list selects it, and the Linux jobs have no ffmpeg, so it would skip in the dbpins runner. The unit test already guards the gate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review summary: reviewed 03486ed, fixes pushed as efa4ab1 The fix is correct and sits at the right place. Addressed (commits on this branch)
The PR body now describes both. Verification
Remaining for maintainers: nothing blocking.
Validated features: no passed case on the v1.0 board reaches this change. #1254 (Audiobooks, Server) has no recorded results, so its C1 and C5 are unaffected as validated cases. Audiobooks are a labelled beta. User manual: unaffected. The audiobook libraries page already says files play in natural filename order, and this change makes the server do that. Apple/Android: no follow-up needed. Both apps order audiobook parts by Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
🤖 Reviewed with Claude Code (claude-opus-5-5); second opinion from Codex (gpt-6.1-sol). |
Problem
Closes #2220
Related issue: N/A
Validation tasks: changes #1254 C1 and C5 (neither has a recorded result yet)
Every scan of an audiobook library rewrote the part data of its multi-file books. Some books then came back from the Audiobookshelf-compatible API with their parts out of order, and every multi-file book was re-probed and rewritten on the next scan even when nothing on disk had changed. This change stops library ingest from running the filename-based variant pass on audiobook libraries.
The audiobook scanner stores each part with
presentation_kind = 'multipart', a part index in natural path order and the part total, and it skips an unchanged book only while those values hold. After matching, ingest ranFinalizeVariantsByPathPrefixover every scanned root. That recomputes the columns fromnaming.ParseVariantHints, which has no audiobook kind, so it cleared them, or replaced them withmultipart_movieindexes taken fromPart NandDisc Nin the file names. A book with an intro before its numbered parts then listed the intro last, and disc-numbered tracks lost their order within a disc.Approach
libraryingestnow skips the variant pass for audiobook libraries in library, subtree and file ingest. The check lives in the executor rather than invariant_finalize.go, so it doesn't overlap #2218, which rewrites that file. Ebook, manga and video libraries still get the pass: the ebook and manga scanners don't write these columns, and I didn't find anything that reads them there.Libraries that already have rewritten rows repair themselves. The next scan sees those books as changed, rebuilds each one once with the scanner's values, and skips it on later scans. Multi-file books already failed the skip check once rewritten. A single-file book was rebuilt only when it was marked
multipart, so the audiobook scanner's skip check now also rebuilds a single-file book that carries a presentation kind or an edition. The old pass could leave those behind for an{edition-…}tag or a lonePart Nfile name. No migration is needed.Only the server changes. The Jellyfin-compatible API hides audiobook libraries, and the apps need nothing new: part order goes back to what the scanner already intended, and no API changes.
Validation
mainfor audiobooks, passes with the fix.mainthe parts are rewritten, two books come back out of order and every book is re-probed on the second ingest. With the fix all of that passes, including a library whose rows were rewritten by an earlier build, and a single-file book left with a stale edition and presentation kind. The test was removed from the branch because no CI list selects it and the Linux CI jobs have no ffmpeg; it was run locally against base and head.go test ./internal/libraryingest/,go vetandgolangci-lint --new-from-merge-baseon the package: clean. I left the full lint and test matrix to CI.mainthe Audiobookshelf-compatible API listed two of the three test books out of order, and a scan of the unchanged library re-indexed all three. After I switched the same database to this branch, the first scan rebuilt the three books once and the next one skipped all three, with every book back in order.Benchmarks
A scan of the unchanged three-book test library re-probed and rewrote 3 of 3 books on
main(skipped=0) and 0 of 3 with this change (skipped=3). The test files are one-second clips, so wall time isn't meaningful at this size, and I haven't measured a large library. On a real library the saving is one ffprobe pass over every part of every multi-file book, on every scan.Evidence
Surface: the Audiobookshelf-compatible API (
GET /api/items/{id}?expanded=1, file names inmedia.tracks) and the scan log, on a local dev build with three test books. Before ismainat bf63b3d, after is this branch at 98f414e on the same database.processed=3 failed=0 skipped=0processed=3 failed=0 skipped=3Evidence: https://evidence.siloserver.org/r/silo-server/pr-2221/
Risks
The first scan after upgrading rebuilds each multi-file audiobook once (one ffprobe pass per part), because its stored rows no longer match. Later scans skip unchanged books. Nothing changes for other library types.
Checklist
AI Disclosure
AI-assisted with Claude Opus. I directed the task and designed the work.
Note
Fix audiobook ingest to skip variant finalisation
finalizesVariantspredicate in executor.go soExecutor.ingestruns variant finalisation only for non-audiobook folder types. Audiobooks and video files differ in metadata ownership, which the new comment documents.Scanner.audiobookFolderShouldSkipin audiobook_scan.go: a single-file audiobook is only safe to skip when it has no presentation metadata and no edition key. Otherwise it falls through to reconciliation to clean up stale metadata from earlier filename-based processing.TestIngestSkipsVariantFinalizationForAudiobooksin executor_test.go covering library, subtree, and file ingest modes across movie, series, mixed, ebook, audiobook, and whitespace-padded audiobook folder types.Macroscope summarized efa4ab1.