Repository navigation
fix: apply rules to contents of a folder moved into a watched folder - #78
Merged
Merged
Conversation
FSEvents only reports the folder itself when it arrives with its contents: the files inside were created outside the watched tree and never generate events of their own, so the watcher evaluated the folder and stopped. Run Now processed the same files fine, because it walks the tree. When a settled arrival is a directory, rescan its subtree before finishing. The arrival's includesContents snapshot already waited for everything inside to stop changing, so the entries can be evaluated immediately; the fingerprint cache keeps a rescan from re-evaluating paths whose own events also arrived. Fixes lab421#70
…files outside the watched folder
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.
Fixes #70.
Problem
Moving a folder into a watched folder left the files inside it unprocessed by automatic watching, even with the rule's scope set to All Levels. Run Now processed the same files fine.
Root cause
FSEvents only reports the folder itself when it arrives together with its contents: the files inside were created outside the watched tree, so no
FileEventsentries are delivered for them.WatcherCoordinatorsettled the arriving folder (the whole-tree fingerprint wait already covers its contents) and then ranhandle(path:)on the folder path alone — the subtree was never walked.Fix
When a settled arrival is a directory,
checkSettlednow rescans its subtree via the existinghandleRescanSubtree, the same path aMustScanSubDirsrecovery or a deferred-descendants settle already takes. Because the arrival'sincludingContentssnapshot only resolves once everything inside has stopped changing for a full settle interval, the entries are evaluated immediately (waitsForSettledFiles: false) — matching Run Now semantics, and giving folder moves the same mid-transfer protection file arrivals already have. The fingerprint cache keeps the rescan from re-evaluating paths whose own events also arrived, and depth limits frommaxRuleDepthare respected as in Run Now.Three-path consistency (per AGENTS.md)
Verification
swift buildclean.swift test: 330 tests in 28 suites, all passed (329 existing + 1 new).WatcherCoordinator.swiftstashed (old code), the new testfolderArrivingWithContentsProcessesThemWithoutTheirOwnEventsfails with 4 issues; with the fix, all 8WatcherSettlingTestspass.