Repository navigation
Fix folder watch crash on a media path that cannot be read - #1653
Open
Dev-next-gen wants to merge 1 commit into
Open
Dev-next-gen wants to merge 1 commit into
Dev-next-gen wants to merge 1 commit into
Conversation
find_tasks() stats every candidate file to build its size+mtime stamp, but os.walk lists names without stating them. A dangling symlink with a media extension, or a file removed since the scan started, makes os.path.getsize raise FileNotFoundError and aborts the whole scan, so no later file in the folder is queued. Take the stamp once, guarded, and skip the file when it cannot be read.
This branch has not been deployed
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.
A watch folder that holds a dangling symlink with a media extension stops folder watch. I dropped a single
dangling.mp3symlink pointing at a file that does not exist into the watched folder and calledfind_tasks():os.walkreturns names without stating them, and the duplicate check added in #1556 callsos.path.getsizeandos.path.getmtimeon every candidate path. Python builds the right hand tuple before comparing it, so the stat runs even for a path that was never emitted. The same two unguarded calls run again aftertask_found.emit, there after the model download, which can take minutes. Sincefind_tasksis the slot connected todirectoryChanged, the exception ends the scan and nothing listed after the unreadable path gets queued.A symlink is just the deterministic way to trigger it. The same stat fails when a file is deleted between the scan and the check, which is routine with "delete processed files" on, or on a network folder.
This takes the stamp once, guarded, and skips the file when it cannot be read. The stamp is reused when recording the emitted path, so the second pair of stat calls is gone as well. The duplicate check itself is unchanged, and I confirmed an mp3 already recorded in
paths_emittedwith its current size and mtime is still skipped.I proved it by calling the real
find_tasks()on a folder holding only the dangling symlink: it raisesFileNotFoundErrorbefore the change and completes without emitting a task after it. The added test does the same and skips itself on platforms that cannot create symlinks.Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.