Open bicarlsen opened 10 months ago
In the cases where a resource's path changes but it is still being tracked and the original path is being emitted, this could lead to confusing behavior.
I made a proof of concept crate that gets a file's path from the id information provided in the file-id
crate.
PollWatcher
will emit Remove(Any)
for all the children and the root folder after the root folder is deleted/renamed/moved. If the folder is created again, Create(Any)
will be emitted for the root folder and all the children.
There is inconsistent behavior when modifying the root resource (file or directory) in different ways, so wanted to document them. This is not so much an error as documentation of these behavior.
Remove(Any)
or no eventRemove(Any)
Modify(Name(From))
Remove(Any)
Remove(Folder)
orModify(Name(Any))
Modify(Name(Any))
Modify(Name(Any))
Modify(Name(Any))
Modify(Name(Any))
Modify(Name(Any))
Remove(File)
orModify(Name(From))
Modify(Name(From))
Modify(Name(From))
Remove(File)
orModify(Name(From))
Modify(Name(From))
Modify(Name(From))
Details
Windows
folder/delete: Using
rm
from command lineRemove(Any)
is emitted for the root, with no events emitted for the children. Using the file explorer no event emitted for root,Modify(Any)
emitted for children.Modify(Any)
emitted for children and subsequent events are still captured.Remove(Any)
events emitted for children.folder/rename: No events emitted for root or children.
std::fs::canonicalize
reports the new path and fails on the original.folder/move: No event emitted for root or children. Subsequent events continue being reported.
std::fs::canonicalize
reports the new path and fails on the original.file/delete:
Remove(Any)
event emitted.Create(Any)
is emitted and all subsequent events are emitted.file/rename:
Modify(Name(From))
event emitted.Modify(Name(From))
with no indication of the resulting name with e.g. a followingModify(Name(To))
.Modify(Name(Both))
was emitted with both the paths being the original.Create(Any)
was emitted. Subsequent events are emitted for the new file.Modify(Name(To))
event was emitted. Subsequent events are emitted for the new file.file/move:
Remove(Any)
event emitted.macOS
folder/delete: If removed from command line with
rm
aRemove(Folder)
event is emitted. If deleted from finder aModify(Name(Any))
is emitted with the original path.Create(Folder)
emitted if new folder created at original path.Modify(Name(Any))
emitted if a folder is renamed or moved to the original path.folder/rename:
Modify(Name(Any))
emitted with original path. Subsequent events not emitted.Modify(Name(Any))
is emitted with the original path.folder/move:
Modify(Name(Any))
emitted with original path.Create(Folder)
emitted if new folder created at original path.Modify(Name(Any))
emitted if a folder is renamed or moved to the original path.file/delete:
Modify(Name(Any))
emitted with original path.Create(File)
event is emitted. If another file is moved or renamed to the original path, aModify(Name(Any))
event is emitted. Subsequent events on the new file are emitted.file/rename:
Modify(Name(Any))
emitted with original path.file/move: Same as file/rename.
Linux
folder/delete: If removed from command line with
rm
aRemove(File)
event is emitted. If deleted from finder aModify(Name(Any))
is emitted with the original path.Modify(Name(From))
event is emitted.folder/rename:
Modify(Name(From))
emitted.std::fs::canonicalize
reports the new path and fails on the original.folder/move: Same as folder/rename.
file/delete: Same as folder/delete.
file/rename: Same as folder/rename.
file/move: Same as folder/rename.
Note: I performed the tests using
notify_debouncer_full