Comments (6)
My current suggestion is to set the Op filter globally at the Watcher level instead of for each Watch added. Preferably in such a way that it cannot be changed later. Perhaps something like:
watcher, err := fsnotify.NewWatcher(fsnotify.Create|fsnotify.Write)
- The filter can be passed to each adapter to have the OS filter out events the best it can.
- A final user-space filter can catch any outliers without requiring the significant amount of bookkeeping of the previous implementation.
- For the same reasons that directory watches are easier to manage, a user-space recursive watcher will be simpler to implement, whether included in fsnotify or externally.
from fsnotify.
I like your proposal of doing the Ops filtering on creation of the watcher.
One usually creates such a watcher with a purpose in mind and the events being delivered are usually suitable for this purpose for the lifetime of the watcher. And after all this is just an optimization. One can always choose a broader scope in order to be sure.
So maybe an additional simple creation function like NewGreedyWatcher
might be useful OR an additional complex creation function like NewFilteredWatcher
. One of those is meant to be without arguments.
from fsnotify.
The current code of Add()
contains:
const agnosticEvents = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF
var flags uint32 = agnosticEvents
So basically the flags are hard-coded to the ones above. Would there be any opposition to adding another API, like:
func (w *Watcher) Add(name string) error {
return w.AddWithFlags(name, agnosticEvents)
}
func (w *Watcher) AddWithFlags(name string, flags uint32) error {
// mostly the same code as the current Add() but use flags passed in argument
I need to ignore IN_DELETE_SELF
because it's misleading in my case (and causes correctness issues in my code), I only care about IN_DELETE
.
from fsnotify.
@tsuna The problem with adding a new API like that is that the flags differ from platform to platform. That's partly why I'd like to split out inotify #173 so it can be used independently in special Linux-only cases.
This issue is tracking a more general solution, which may be a ways off yet.
from fsnotify.
I hear you, although I personally don't think it's a big problem that the flags differ across the platforms, since this API would just take a uint32
and what values make sense for this API could be platform specific. So this would be a more advanced API for those needing the extra control.
Now when I reviewed the open issues I missed #173, that's obviously a more elegant solution, and at this rate between this bug and #97 and #123, it's very hard for me to get correctness out of fsnotify, so I was considering writing my own little inotify wrapper anyway, so I'm glad to hear that this is being considered.
For now I think I'll just fork the project to quickly fix/hack the bugs that are impacting me.
from fsnotify.
Pull requests are welcome, and once we have more people reviewing and merging pull requests, things should start to move faster.
I think breaking out the low-level platform specific libraries (such as #173) will also help there. It should allow experts in inotify to work on that without worrying about the cross-platform API, and others to tackle cross-platform consistency without dealing with all the low-level details.
from fsnotify.
Related Issues (20)
- The reason why queue or buffer overflow? HOT 1
- Support for intermediary multiplexer like watchman HOT 5
- Infinite WRITE events when watching $TMPDIR on MacOS HOT 3
- Write Events Fired Multiple Times for File Changes HOT 1
- Can we add a polling interval to the watcher to scan the mentioned directory after a particular time interval and not continuously? HOT 6
- Proposed approach for a different type of fanotify backend HOT 10
- Inconsistent behavior of WatchList on Windows and Unix HOT 5
- Received an unexpected is to see HOT 2
- There is a directory with some files in it, watch this directory and how to return the files that already exist. HOT 1
- panic in v1.7.0 HOT 8
- illumos: track renames HOT 1
- documentation: double `to to` in Add method of fsnotify.Watcher HOT 3
- support of CLOSE_WRITE event does not work HOT 11
- When removing symlink no events happens on MacOS. HOT 1
- When adding invalid directory to watch list it is return error but also adding to list too.
- Apply watcher to subdirectories HOT 1
- Watch /tmp doesn't work on MacOS
- Looking forward to file opening events in Windows system HOT 1
- Triggering the Create Op leads to EOF issues HOT 2
- The specified executable is not a valid application for this OS platform.At line:1 char:1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsnotify.