Skip to content

Commit

Permalink
Revert "Add sanity check to fsnotify paths (#31)" (#34)
Browse files Browse the repository at this point in the history
This reverts commit 2cb8794.
  • Loading branch information
mokiat authored Mar 4, 2024
1 parent 151ccd1 commit 90889cf
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions internal/pipeline/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func Watch(

proc := &watchProcess{
verbose: verbose,
rootDirs: dirs,
watcher: watcher,
watchFilter: watchFilter,
trackedPaths: ds.NewSet[string](1024),
Expand Down Expand Up @@ -69,7 +68,6 @@ func Watch(

type watchProcess struct {
verbose bool
rootDirs []string
watcher *fsnotify.Watcher
watchFilter *filesystem.FilterTree

Expand Down Expand Up @@ -111,10 +109,6 @@ func (proc *watchProcess) handleEvent(event fsnotify.Event) *ds.Set[string] {
}

func (proc *watchProcess) startWatching(root string) *ds.Set[string] {
if !proc.isSanePath(root) {
return nil
}

result := ds.NewSet[string](1)

filesystem.Traverse(root, func(p string, isDir bool, err error) error {
Expand Down Expand Up @@ -156,10 +150,6 @@ func (proc *watchProcess) startWatching(root string) *ds.Set[string] {
}

func (proc *watchProcess) stopWatching(root string) *ds.Set[string] {
if !proc.isSanePath(root) {
return nil
}

result := ds.NewSet[string](1)

for p := range proc.trackedPaths.Unbox() {
Expand Down Expand Up @@ -196,18 +186,6 @@ func (proc *watchProcess) isTracked(path string) bool {
return proc.trackedPaths.Contains(path)
}

// isSanePath returns whether the path appears to be legit, since fsnotify
// has issues on some platforms where after a Remove it starts emitting
// empty paths or ones relative to root.
func (proc *watchProcess) isSanePath(path string) bool {
for _, root := range proc.rootDirs {
if strings.HasPrefix(path, root) {
return true
}
}
return false
}

func (proc *watchProcess) logFSWatchEvent(event fsnotify.Event) {
if proc.verbose {
log.Printf("Filesystem watch event: %s", event)
Expand Down

0 comments on commit 90889cf

Please sign in to comment.