Repository navigation
Conversation
Renaming moved audiobook files one by one and only carried the sidecars Chaptarr tracks. Untracked ones (AudioBookShelf cover.jpg/metadata.json, .opf, desc.txt...) stayed in the old folder, and a library watcher saw a new folder fill up file by file: AudioBookShelf created a new item and wrote its own sidecars there before Chaptarr moved the tracked ones, which then failed with "File already exists". When every audiobook file of a folder goes to the same new folder and nothing else lives there, the folder is now moved in one step. If the destination already exists, the sidecars are moved ahead of the audio files, never overwriting an existing file. Tracked metadata and extra files that a folder move already carried are re-pointed instead of failing to move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extras are renamed after the book file (e.g. "<book file>.jpg"). After a folder move, the tracked file sits in the new folder under its old name, so looking only for the new name failed with FileNotFoundException and left the extra's stored path stale. Look for the carried file under its old name and rename it in place when needed. 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
Renaming moved audiobook files one by one and only carried the sidecars Chaptarr tracks in
MetadataFiles. Untracked ones (AudioBookShelfcover.jpg/metadata.json,.opf,desc.txt…) were left in the old folder, and a library watcher saw a new folder fill up file by file: AudioBookShelf created a new item and wrote its own sidecars there before Chaptarr moved the tracked ones, which then failed withFile already exists.RenameBookFileServicenow groups the audiobook files of a rename by source folder. When every file of a folder goes to the same new folder:Directory.Move). Everything in it follows, and watchers see a single rename. A file whose own name also changes is then renamed inside the new folder by the usual mover.The relocation is skipped (old behaviour) when:
If the folder move throws (e.g. cross-device), it logs a warning and falls back to moving files one by one.
MetadataServiceandExtraFileManagernow re-point a tracked file that a folder move already carried (old path missing, new path present) instead of failing to move it.Audiobook plans are computed before the loop, which is safe because they only depend on naming; ebook plans are still computed in the loop, after the audiobook moves are recorded in the batch context.
Fixes #304
Database Migration
NO
How was this tested?
RenameBookFileServiceFixture, with an in-memory disk fake:MetadataServiceSidecarOverwriteFixture: tracked metadata already carried by a folder move is re-pointed, not moved.Chaptarr.Core.Testrun: 3051/3051 passing (Linux, .NET 10 SDK container).Chaptarr.Core.dlloverrobertlordhood/chaptarr:0.9.965(Docker, library on an rclone/pCloud mount, AudioBookShelf watching the same folders). Both instances start cleanly, and the rename preview and API work as before.🤖 Generated with Claude Code