Skip to content

Commit

Permalink
docs: add more context to ignoring Windows attribute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
milas committed Jul 1, 2021
1 parent 7593241 commit 3ee2a2f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,21 @@ func (w *Watcher) Add(name string) error {
}

// When reporting file notifications, FILE_ACTION_MODIFIED includes changes to file attributes;
// so attribute handling is broken for Windows (op.Chmod will NEVER get used in practice)
// so attribute handling is broken for Windows (op.Chmod will NEVER get used in practice).
//
// To prevent events for attribute changes erroneously showing up as file modifications,
// FILE_NOTIFY_CHANGE_ATTRIBUTES (sysFSATTRIB) is excluded from the notify filter.
// NOTE: This means attribute changes will NOT be reported for Windows.
//
// This means attribute changes will NOT be detected on Windows, as this has been deemed
// better than misreporting them as file modifications.
//
// For most purposes, especially since there is no execute bit in Windows/NTFS, these events
// are uninteresting, but it appears some security/AV/backup software can trigger excessive
// attribute changes resulting in lots of events for otherwise unchanged files.
//
// To accurately get Chmod events, a substantial refactor would be needed to set up two
// underlying watchers - one with a FILE_NOTIFY_CHANGE_ATTRIBUTES filter and another with
// the remaining filters, so that attribute changes can be reliably detected.
//
// See also:
// * ReadDirectoryChangesW flags: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readdirectorychangesw
Expand Down

0 comments on commit 3ee2a2f

Please sign in to comment.