fix(scan): clear stale legacy file columns when a book's folder is gone#711
Open
kevinheneveld wants to merge 1 commit into
Open
Conversation
When a scan finds an audiobook's BasePath directory missing, ScanJobProcessor removes the tracked AudiobookFile rows and nulls BasePath — but leaves the legacy single-file columns (FilePath/FileSize) populated. LibraryListService then derives hasAnyFile = hasTrackedFiles || !string.IsNullOrWhiteSpace(FilePath), so the book keeps reporting "Downloaded" with zero files forever and, being treated as complete, never gets re-searched. Clear FilePath/FileSize alongside BasePath in the missing-folder branch so the book correctly reverts to "no file" / wanted. The manual scan path already does this via MigrateLegacyFilePathAsync; this brings the background worker in line. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
Audiobooks can show "Downloaded" status with zero files and silently stop being re-searched.
LibraryListServicederives file presence from a backward-compat fallback:So a book with a stale legacy
FilePath(and no tracked files) reads ashasAnyFile == true→ "Downloaded", while the UI's FileCount (from the realAudiobookFilesrows) is 0. It's also treated as complete byAudiobookWantedEvaluator, so it never re-searches.Root cause
ScanJobProcessor.ProcessJobAsynchas a dedicated branch for when a book'sBasePathdirectory has vanished: it deletes the trackedAudiobookFilerows and setsaudiobook.BasePath = null, then returns — but it never clears the legacyFilePath/FileSizecolumns. The later "legacy filePath migration" block that would clear them is downstream of this earlyreturn, so it's skipped.Result: a book whose whole folder disappeared keeps its legacy columns set → permanent phantom "Downloaded".
Fix
Clear
FilePath/FileSizealongsideBasePathin the missing-folder branch:The synchronous/manual scan path (
LibraryManualScanWorkflow.MigrateLegacyFilePathAsync) already clears these for a missing file; this brings the background worker in line.Test
Added
ProcessJobAsync_BasePathMissing_ClearsLegacyFileColumns: a book with a non-existentBasePathand populated legacy columns is scanned, andFilePath/FileSizeare asserted null afterward (read through a fresh DI scope to bypass the test context's identity map). Full suite green (1016 tests).🤖 Generated with Claude Code