fsnotify
fsnotify copied to clipboard
Notifications when nothing happened after the computer starts or wakes from sleep mode
On a Windows 10 machine I have a Go program which uses fsnotify
to watch for changes for a .txt file. When i open the .txt file in notepad without changing anything and closing without saving, fsnotify notifies about a file change. This happens only one time after the Computer has started or returned from sleep-mode
This is how I listen for file change events:
for {
select {
case _, ok := <-fw.Events:
if ok {
log.Println("File changed")
}
case err, _ := <-fw.Errors:
log.Println("FileWatcher error:", err)
}
}
Fsnotify registered a change for .txt
at : 20:25
The windows properties for .txt
shows last changes at: 19:12
Maybe you should have a try fsutil behavior set disablelastaccess 1
.
Have you ever seen the file last access time?
@cobolbaby I found a pattern in this issue.
It seems to only happend 1 time after the computer starts or when the computer has been in sleep mode. Do you get me?
Also I have not access to fsutil
Yes in the previous thread .txt
had last access time at 20:25
Both FILE_NOTIFY_CHANGE_LAST_ACCESS and FILE_NOTIFY_CHANGE_LAST_WRITE will emit FILE_ACTION_MODIFIED event. I think there should be an option to disable last access time triggering Write op event.
I think #520 probably fixed this; I think some program changed file attributes on wakeup, which would show up as Write events because that's how the Windows API sends them or some reason.
Let me know if it's not fixed with that PR and we can look further.