Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Exclusion lists #42

Open
smashwilson opened this issue Oct 5, 2017 · 3 comments
Open

Exclusion lists #42

smashwilson opened this issue Oct 5, 2017 · 3 comments

Comments

@smashwilson
Copy link
Contributor

Support per-watch-root exclusion lists, likely expressed as arrays of globs.

@icetee
Copy link

icetee commented Nov 22, 2017

Then there will be such a capability? https://github.com/kaelzhang/node-ignore
Is it expected in the near future?

@smashwilson
Copy link
Contributor Author

It is something I want to do, but won't get to soon.

Some of the complications that will need to be dealt with here include:

  • Multiple PathWatchers with different options can be backed by the same NativeWatcher. This means that each NativeWatcher will need to be able to subscribe to events on the union of the path sets expected by each PathWatcher (or, equivalently, with an exclusion list that's the intersection of those from its PathWatchers), displaced by relative paths as appropriate.
  • Exclusion filters will need to be represented in both JavaScript and C++ and passed to the worker thread along with each COMMAND_ADD message.
  • We'll also need to either introduce a new command to modify an existing NativeWatcher's exclusion list, or delete and re-create watch roots as its exclusion lists change.
  • Exclusion lists should be respected when prepopulating a RecentFileCache on MacOS and Windows as well as when recursively building an inotify watcher tree on Linux. The polling thread will also need to respect the list.

As a workaround until then, you can always filter watcher events JavaScript-side:

const watcher = require('@atom/watcher')
const ignore = require('ignore')

const ig = ignore().add(['.git/*', 'node_modules'])

const w = await watcher.watchPath('/root/path', {}, events => {
  for (const event of events) {
    if (ig.ignores(event.path)) continue;

    //
  }
})

@icetee
Copy link

icetee commented Nov 22, 2017

Thanks for your description and JS example!
It requires much more development than I thought first. 🙈

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants