Repository navigation
fix: Manual Import from an ebook request imports the ebook and leaves the audiobook alone - #492
Merged
Merged
Conversation
… audiobook The details modal opened from an ebook request card now passes the request type and id to the Manual Import browser. The browser lists ebook files (`type=ebook`), and the import names the ebook request. The server takes the type from the stored request (a disagreeing flag, or files of the other kind, is a 400), recycles or creates only an ebook request, and queues the ebook organize branch with the selected ebook files; that branch imports the preferred selected file and its source cleanup removes only that file. An ebook import no longer recycles or re-organizes the audiobook request. EBOOK_EXTENSIONS is the one ebook extension list (now with .azw); the organizer's format list and preference order derive from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #278
What changed
requestType: 'ebook'and its request id (src/components/audiobooks/AudiobookDetailsModal.tsx). An audiobook card, and a book opened without a request, open the audiobook import as before.src/components/audiobooks/ManualImportBrowser.tsx,manual-import/BrowsePhase.tsx,ConfirmPhase.tsx): an ebook import browses withtype=ebook, lists ebook files only, shows "Manual Ebook Import" and "N ebook file(s)", and sendsrequestIdandrequestTypewith the import. The audiobook import sends the same body as before.src/app/api/admin/filesystem/browse/route.ts): newtypequery parameter (audiobook, the default, orebook; anything else is a 400). Ebook mode returnsebookFilesand no disc folders.src/app/api/admin/manual-import/route.ts) with the newsrc/lib/services/manual-import.service.ts:resolveImportTarget: the stored request's type decides the import's type. ArequestTypethat disagrees with it is a 400, an unknown type is a 400, and a missing or deleted request is a 404. A request for another book is a 400.resolveEbookSelection: an ebook import accepts only ebook files directly in the folder. A selected audio file, a path or..in a name is a 400. With no selection it takes the folder's ebook files.claimImportRequest: recycles or creates a request of the import's kind only. An ebook import reuses the named ebook request (or the newest ebook request of the book), else creates one with the available audiobook request as its parent. It never recycles, resets or re-organizes the audiobook request. An active request of that kind is a 409.src/lib/processors/organize-files.processor.ts): the existing ebook branch now honoursselectedFiles. It imports the preferred selected ebook file, and its source cleanup removes only that file, through the same delete guard (cleanupSourceAfterOrganize). A selection with no ebook in it fails the job with a clear message.EBOOK_EXTENSIONS(src/lib/constants/audio-formats.ts, now with.azw) is in preference order. The organizer's format list andfindEbookFile's preference order derive from it (src/lib/utils/import-inventory.ts,src/lib/utils/file-organizer.ts). The newpreferredEbookFile()picks from a selection by that order.documentation/features/manual-import.md(ebook import, Fixed Issues entry),documentation/integrations/ebook-sidecar.md(format list, Fixed Issues Review guidelines and start fixing issues #3),documentation/testing/e2e-harness.md(new spec row).Why
The details modal never passed the request type to the Manual Import browser. So Manual Import from an ebook request card was the audiobook import. It listed and accepted only audio files, then recycled the book's audiobook request (even one already
available) and re-ran the audiobook organize on the folder, with source cleanup if it was ticked. The ebook request stayed failed, and the folder's audio was imported into the library a second time.Evidence
e2e/specs/regressions/278-ebook-manual-import.spec.ts. It sets up a book with anavailableaudiobook request, imported fromSeed Track.mp3, and a failed ebook request. The source folder holdsBook.mp3andBook.epub. The spec opens Manual Import from the ebook card in/requests, turns cleanup on and imports.Book.epub. The import names the ebook request. Only that request is organized, and it endsdownloaded. The epub lands in the book's library folder with the same bytes. The audiobook request is untouched (status, progress,updatedAt,completedAt). The library folder still holdsSeed Track.mp3and noBook.mp3. Cleanup removedBook.epuband keptBook.mp3.mainimage (333c88e): 16 of its checks fail on an assertion. The mp3 is listed and the epub is not. No request id or type is sent. The organize job runs on the audiobook request, which leavesavailable, and the ebook request staysfailed.Book.mp3is copied into the library, and cleanup removes the mp3 rather than the epub.tests/api/admin-manual-import-ebook.routes.test.tsruns the real routes on a real temp folder. It covers type resolution, the 400/404/409 cases, ebook-only selection and the requests touched.tests/processors/organize-ebook-manual-import.test.ts: the ebook branch imports the selected file and cleans up only that file.tests/constants/ebook-extensions.test.ts: the one list, its order,.azw.tests/components/audiobooks/ManualImportBrowser.test.tsx: the browse URL and the import body, for each type.tests/components/audiobooks/AudiobookDetailsModal.manual-import.test.tsx: the modal passes the type and request id.main'ssrc: 21 failed, 10 passed. 20 fail on an assertion. The other fails becausepreferredEbookFiledid not exist yet. On this branch: 31/31, and 53/53 with the two existing manual-import test files.Checks
vitest relatedon the changedsrcfiles, plus the new test files): PASS, 141 files, 1843 passed, 1 skippedtsc --noEmitclean, e2e type check clean; ESLint reports nothing new in the touched files compared withmain, and the new files are clean)278-ebook-manual-import,434-multi-disc-import,smoke,verified-import,verified-import-mapped(sab-remote),library-delete-guard,242-delete-guard(media-bind): PASS (1, 5, 1, 7, 1, 15 and 12 passed)Risk and rollback
downloadedandavailable, the statuses the audiobook import already recycled.filePath,fileFormat: 'epub',status: 'completed'). This is existing behaviour of every ebook import and is left as is. The row'sfilesHashis unchanged. With the default ebook path template the folder is unchanged too; a separate ebook path template repoints the row'sfilePathto the ebook folder, as every automatic ebook import already does.EBOOK_EXTENSIONS; both are the same as before..azw, which the organizer already accepted, joinsEBOOK_EXTENSIONS, so the request download route (/api/requests/[id]/download) now also serves an.azwebook. The ranking algorithm's title-format list is separate and unchanged.requestTypethat disagrees with the named request, or audio files to an ebook import, now gets a 400.Release note
🤖 Generated with Claude Code