-
-
Notifications
You must be signed in to change notification settings - Fork 966
Closed
Description
Describe the bug
On MacOS, there is a weird behavior if you use rm -fr to delete a watched directory. You get a flurry of REMOVE events in no particular order. After the REMOVE event for the directory itself is processed, any subsequent REMOVE events for files in that directory are not processed correctly.
To Reproduce
Steps to reproduce the behavior:
- Create a test folder:
mkdir ~/testdir && cd ~/testdir - Use the demo code under README to watch that folder. Keep watching while you do the remaining steps.
- Create some files in test folder:
touch a b c d e f g - Delete folder:
cd .. && rm -fr testdir - The demo code will produce incorrect removal events:
% go run test.go
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/a"
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/b"
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/c"
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/d"
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/e"
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/f"
2022/10/10 15:25:23 event: CREATE "/Users/sergey/testdir/g"
2022/10/10 15:25:44 event: REMOVE "/Users/sergey/testdir/g"
2022/10/10 15:25:44 event: REMOVE "/Users/sergey/testdir/a"
2022/10/10 15:25:44 event: REMOVE|WRITE "/Users/sergey/testdir"
2022/10/10 15:25:44 modified file: /Users/sergey/testdir
2022/10/10 15:25:44 event: REMOVE ""
2022/10/10 15:25:44 event: CREATE "."
2022/10/10 15:25:44 event: REMOVE ""
2022/10/10 15:25:44 event: CREATE "."
2022/10/10 15:25:44 event: REMOVE ""
2022/10/10 15:25:44 event: CREATE "."
2022/10/10 15:25:44 event: REMOVE ""
2022/10/10 15:25:44 event: CREATE "."
2022/10/10 15:25:44 event: REMOVE ""
2022/10/10 15:25:44 event: CREATE "."Which operating system and version are you using?
ProductName: macOS
ProductVersion: 12.5.1
BuildVersion: 21G83
Reactions are currently unavailable