Repository navigation
Fix folder watch crash on a media path that cannot be read - #1653
raivisdejus merged 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.
|
@Dev-next-gen Thanks for your contribution. Seems you have created a good tool to find issues! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1653 +/- ##
==========================================
- Coverage 83.56% 83.53% -0.03%
==========================================
Files 116 116
Lines 13845 13851 +6
==========================================
+ Hits 11569 11571 +2
- Misses 2276 2280 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The red Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5. |
|
Yes, Macos Build failure is the expected behavior |
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.