-
Notifications
You must be signed in to change notification settings - Fork 252
Add an IsAttrib method on the FileEvent struct #79
Conversation
Interesting. I wonder if some of what I thought was due to Spotlight #62 was actually due to the issue you were seeing. Has this been tested on BSD, Linux, Windows and OS X? (see Contributing) |
@abustany See fsnotify_test for the integration tests we currently have. |
Also, I think your description of IsAttrib here is a little more meaningful than "attribute change" in the comments. |
Sorry about the delay, have been taken by other activities so far - I'll try to revive this PR soon taking your comments into account. |
Fyi, I've mentioned this in the |
Maybe add IsAttrib to |
I would really like to see this go in. It helped me solve an issue I had with revel on OSX. https://github.com/robfig/revel/issues/460 |
"funny" that I'm also the one that wrote the commit that triggers the revel bug... I agree about the String() method remark, I'm still fairly busy but will bump this task up on my list of priorities. |
This IsAttrib function can be used to distinguish events that only concern a file's metadata (eg. atime, mtime etc.).
This counter is counting "IsModify" events.
This is useful when you want to check the event count delta after doing some operations.
|
Okay, just one concern. I noticed that attrib is still part of Modify. So an attribute change will still show IsModify() to be true as before, but also IsAttrib() to be true. Is this what we want? I'm fine with it as long as we are aware this is how it works. |
The reasoning behind that was that I wanted the change to be backwards compatible... Not sure what kind of guarantees we want to give in this regard. The question of whether an attribute change is a "modify" event or not is maybe more of a philosophical one, I must admit I don't have a strong opinion there :) |
Add an IsAttrib method on the FileEvent struct
I like that its backwards compatible, looks good to me. |
A backwards incompatible change to IsModify() is something we could consider for the new os/fsnotify API. |
Handle ERROR_MORE_DATA on Windows (howeyc/fsnotify#49) Run tests in random temp directories (howeyc/fsnotify#57) Fix: RemoveWatch is not removing the path from the watch list The issue was that files watched internally were not being removed when the parent directory's watch was removed. (howeyc/fsnotify#71) Fix: Race on OS X between Close() and readEvents() (howeyc/fsnotify#70) Fix: deadlock on BSD The removeWatch routine could return without releasing the lock on w.bufmut. This change unlocks the mutex before checking for errors. (howeyc/fsnotify#77) Add an IsAttrib method on the FileEvent struct (howeyc/fsnotify#79) Fix: a few typos Test helpers for shared setup. LGTM=iant R=golang-codereviews, dave, alex.brainman, gobot, bradfitz, iant CC=bradfitz, bronze1man, cespare, denis.brandolini, golang-codereviews, henrik.edwards, jbowtie, travis.cline, webustany https://golang.org/cl/58500043
Handle ERROR_MORE_DATA on Windows (howeyc/fsnotify#49) Run tests in random temp directories (howeyc/fsnotify#57) Fix: RemoveWatch is not removing the path from the watch list The issue was that files watched internally were not being removed when the parent directory's watch was removed. (howeyc/fsnotify#71) Fix: Race on OS X between Close() and readEvents() (howeyc/fsnotify#70) Fix: deadlock on BSD The removeWatch routine could return without releasing the lock on w.bufmut. This change unlocks the mutex before checking for errors. (howeyc/fsnotify#77) Add an IsAttrib method on the FileEvent struct (howeyc/fsnotify#79) Fix: a few typos Test helpers for shared setup. LGTM=iant R=golang-codereviews, dave, alex.brainman, gobot, bradfitz, iant CC=bradfitz, bronze1man, cespare, denis.brandolini, golang-codereviews, henrik.edwards, jbowtie, travis.cline, webustany https://codereview.appspot.com/58500043 Committer: Ian Lance Taylor <[email protected]>
This IsAttrib function can be used to distinguish events that only
concern a file's metadata (eg. atime, mtime etc.).
The background for this commit is an app that I have which
monitors a folder, and reads new files that get copied there. On
OS X (at least, I don't get the same behaviour on Linux with a FS
mounted with the relatime option), reading the file will update the
atime and trigger a new event (creating a loop since then the app
will read the file again, and so on). The IsAttrib method allows me
to filter out attribute events.
Testing has been done on OS X and Linux.