Repository navigation
Merge person and series spellings, and undo a merge, in one transaction - #560
Merged
Merged
Conversation
Merging spellings of a person or a series is now one admin request that rewrites every affected book in one transaction, so a failure or a closed tab no longer leaves some books merged and others not. Undo restores the prior values and their sources through the existing bulk-edit path. Fixes part of #224 (People merge isn't atomic).
MergeSpellings copied EditBooks' loop over editTx but dropped the path that EditBooks adds to a refused book's error, so a refused merge did not say which book. Both now call editRefsTx. Part of #224.
A merge's Undo sends one bulk edit per prior override and per 1,000 books. The first failed request stopped the rest, leaving later books merged with no way to retry. Every step now runs, and the error toast offers Undo again for only the books whose step failed. Part of #224.
The IN list was sized to the number of spellings, so each count prepared a new statement and churned the per-connection statement cache. The spellings now go through json_each, and the transaction closure no longer assigns the outer err. Part of #224.
The series-spellings and MergeSuggestion comments still sent readers to the bulk edit, which no longer applies a merge. Part of #224.
The repeat merge shadowed the reply body, so hoisting that line would have left the Undo loop checking nothing. Part of #224.
The console undid a merge with one bulk edit per group of up to 1,000 books, so a closed tab lost the rest, one book a scan had moved failed its whole group with a 404 that named no book, and Undo overwrote a book edited since the merge. POST /admin/books/merge/undo takes the merge's reply back and puts every book that still carries the merged spelling back in one transaction; a book gone from the index or edited since is left as it is and named in "skipped", and the console says which. A merge now changes at most 5,000 books (400 too_large, nothing written), so its transaction stays short on a slow disk and its Undo fits one request, and a merge scoped to a missing library answers 404 (a podcast library 409) instead of an empty success. Part of #224.
The merge's audit entry named only the target and the book count, so the log could not say which spellings were folded in or whether one library or all of them were touched. It now lists the sources (the first 20, each cut at 120 characters) as "Merged spellings" and the library when the merge was scoped to one. Part of #224.
KodeStar
added a commit
to KodeStar/audiosilo-docs
that referenced
this pull request
Nov 22, 2026
Documents KodeStar/audiosilo-server#560: merging author, narrator and series spellings changes every matching book or none, and Undo puts them back in one request. - Admin pages: Library > Authors and Narrators ("Merging two spellings": whole-credit matching, the 5,000-book limit, what Undo puts back and what it leaves and names), Health's series spellings (its own library only, linking to the author section), the audit log's "Merged spellings" and "Reverted" entries. - Developer pages: `POST /admin/books/merge` and `POST /admin/books/merge/undo` in the API reference (shapes, `too_large`, 404, 409 `not_book_library`, `changed` / `not_found`, the audit entries), the console page, the scanner page's note on merged names. - `scripts/server-names.json`: the two new admin routes, pinned to the merged server commit. No screenshots change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merging spellings of an author, a narrator or a series in the console is now one server request in one transaction, and so is its Undo. A failure or a closed tab no longer leaves some books merged and others not.
POST /admin/books/merge(catalog/merge.go): whole-credit matching (a co-credit naming the spelling keeps it), every matching book changed or none, through bulk edit's per-book path (a refused book is named). Capped at 5,000 books (400 too_large); an unknown library is 404, a podcast library 409not_book_library. Audited as "Merged spellings" with the spellings and the scope.POST /admin/books/merge/undo(catalog.UndoMerge): the console posts the merge's reply back; the books go back in one transaction, books edited since are listed aschangedand books moved by a scan asnot_found, the rest are restored. Its own audit entry.books.id.Part of #224 ("People merge isn't atomic").
Verified live, 17/17 (console in a real browser, en, de, fr, it): a server killed 0.2 s into a 4,500-book merge wrote nothing; a book refused by a trigger rolled back all 4,500; 5,001 books answer too_large; a 4,500-book merge took 0.55 s and its Undo 0.51 s; Undo after an edit and after a rescan move; 404, 409, 403 and 401. Gate: build-admin (1,951 console tests), go build/vet/test -race/golangci-lint on the pure-Go and native SQLite engines.
Docs: KodeStar/audiosilo-docs (paired PR).