Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications when nothing happened after the computer starts or wakes from sleep mode #323

Closed
Muddz opened this issue Feb 5, 2020 · 4 comments

Comments

@Muddz
Copy link

Muddz commented Feb 5, 2020

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

@cobolbaby
Copy link

cobolbaby commented Feb 8, 2020

Maybe you should have a try fsutil behavior set disablelastaccess 1.

Have you ever seen the file last access time?

@Muddz
Copy link
Author

Muddz commented Feb 9, 2020

@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

@reusee
Copy link

reusee commented Apr 2, 2021

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.

@arp242 arp242 changed the title Fsnotify notifies about a file change on Windows when nothing happend to the file Notifications when nothing happened after the computer starts or wakes from sleep mode Aug 4, 2022
@arp242
Copy link
Member

arp242 commented Oct 15, 2022

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.

@arp242 arp242 closed this as completed Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants