| 43 | } |
| 44 | |
| 45 | func (d *fseventNotify) loop() { |
| 46 | for { |
| 47 | select { |
| 48 | case <-d.stop: |
| 49 | return |
| 50 | case events, ok := <-d.stream.Events: |
| 51 | if !ok { |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | for _, e := range events { |
| 56 | e.Path = filepath.Join(string(os.PathSeparator), e.Path) |
| 57 | |
| 58 | _, isPathWereWatching := d.pathsWereWatching[e.Path] |
| 59 | if e.Flags&fsevents.ItemIsDir == fsevents.ItemIsDir && e.Flags&fsevents.ItemCreated == fsevents.ItemCreated && isPathWereWatching { |
| 60 | // This is the first create for the path that we're watching. We always get exactly one of these |
| 61 | // even after we get the HistoryDone event. Skip it. |
| 62 | continue |
| 63 | } |
| 64 | |
| 65 | d.events <- NewFileEvent(e.Path) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // Add a path to be watched. Should only be called during initialization. |
| 72 | func (d *fseventNotify) initAdd(name string) { |