Open nohupped opened 7 years ago
Hey @nohupped , this is a bug in notify
logic. Since inotify sends only file names, we store full paths in memory. However, when directory is moved, these paths are not updated.
Probably, we need to catch IN_MOVE_SELF
events and update in-memory paths afterwards.
Note, that moving watched directories is generally not cross-platform - it is not possible to implement this correctly on Windows.
Hi @ppknap! I try to do this task, but it impossible. I add IN_MOVE_SELF
to InotifyAddWatch
and I caught it, but I can't get new name of folder.
1) IN_MOVE_SELF
don't trigger IN_MOVE_TO
.
2) We have only file description and when I try run os.Readlink
for /proc/self/fd/XXX
it returned only anon_inode:inotify
No way to fix it. Good solution here it drop PANIC, but it breaks current workflow.
Apologies if I missed a way to get around this, and I am not sure if this is the expected behaviour either, but when there is a watcher created for a parent directory for eg:
/tmp/testdirectory
, and if I moved the parent directory itself as/tmp/moved
, any events inside /tmp/moved will be shown as/tmp/directory/
, which is the old path.Code:
Output: Console:
Daemon output:
Console:
Daemon output:
(Shown as
notify.InCreate: "/tmp/directory/anotherdir
instead ofnotify.InCreate: "/tmp/moved/anotherdir"
) Is there any way when the parent directory is moved, it can reflect in the event's path with the updated directory name of the parent directory?