Repository navigation
Conversation
…re library ImportApprovedBooks always moved or copied the file with the book file mover, so a download imported into a root folder marked as a Calibre library bypassed the content server: the book never reached metadata.db and Calibre/Calibre-Web could not see it (issue Chaptarr#205). When the import destination for an ebook resolves to a Calibre library root with settings, hand the file to CalibreProxy.AddAndConvert instead, as UpgradeMediaFileService already does. Calibre picks the folder and SetFields records its path on the BookFile. Tag writing and release extras are skipped for these files because Calibre owns the folder. Relocations of already-tracked files keep the existing path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once AddAndConvert succeeds the book is in Calibre. Treating a failed delete of the download as a failed import left the book untracked, and a retry would add a duplicate to Calibre. Log a warning instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CalibreProxy.SetFields runs after the book is already in Calibre. It dereferenced series links, edition images, genres and ratings without null checks, so a book with no genres or series links threw ArgumentNullException at OrderBy and failed the whole import, leaving the book in Calibre with no Chaptarr record (a retry then added it twice). Treat absent metadata as empty. 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.
Description
A download imported into a root folder marked as a Calibre library is copied into the library folder instead of being added through the Calibre content server. Calibre never sees the book: it is missing from
metadata.dband from Calibre-Web, and it sits in a folder without Calibre's(id)suffix.The cause is that download and manual imports go through
ImportApprovedBooks, which always transfers the file withIMoveBookFiles. The Calibre path (CalibreProxy.AddAndConvert) only exists inUpgradeMediaFileService, which this import route never reaches.This PR adds a small routing step in
ImportApprovedBooks. When the destination Chaptarr would choose for an ebook falls inside a root folder withIsCalibreLibraryand Calibre settings, the file goes toAddAndConvert, the same callUpgradeMediaFileServiceuses. Calibre picks the folder, andSetFieldsrecords Calibre's path on theBookFile. In that case:A second commit makes removing the downloaded source file best-effort once Calibre has accepted the book. If that delete failed the import used to fail, leaving the book in Calibre without a Chaptarr record; a retry then added it to Calibre a second time.
This is deliberately narrow. #132 covers much more (deletion propagation, duplicate reaping, metadata push, cover reconciliation). This PR only stops downloads from bypassing Calibre, so it can land on its own whatever happens with #132.
Fixes #205
Database Migration
NO
How was this tested?
Chaptarr.Core.Test: 3040 passed, 0 failed (3035 ondevelopplus 5 new). The newImportApprovedBooksCalibreDestinationFixturecovers:/data/calibre/librarybacked by alinuxserver/calibrecontent server on port 8181.Diana Jones/Howl's Moving Castle/dw2o9q31.epub) andmetadata.dbgained no rows.Diana Wynne Jones/Howl's Moving Castle (2764)/. A rescan then linked the Chaptarr book file to that path.The third commit null-guards
CalibreProxy.SetFields. It dereferenced series links, edition images, genres and ratings without null checks. A book with no genres or series links threwArgumentNullExceptionafter Calibre had already accepted the file, so the import failed and a retry added the book a second time. A regression test covers it; the test fails ondevelopat the same line as the production crash.Disclosure
This bug was found, diagnosed, fixed and tested by Claude Code running Claude Opus 5.5, working on my own instance at my direction. I reviewed the change and deployed it to my server, where it has run since 2026-10-03.
🤖 Generated with Claude Code