From b7bd2d26645040d53b060f05725ad4a7f68bdeba Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 3 Oct 2016 14:58:08 -0400 Subject: [PATCH] recwatch: Rearrange condition to unconfuse golinter This wasn't a bug, but the go linter is unhappy because it is dumb. --- recwatch/recwatch.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/recwatch/recwatch.go b/recwatch/recwatch.go index ebf4e4f8..75b93beb 100644 --- a/recwatch/recwatch.go +++ b/recwatch/recwatch.go @@ -158,20 +158,22 @@ func (obj *RecWatcher) Watch() error { if global.DEBUG { log.Printf("watcher.Add(%s): Error: %v", current, err) } + if err == syscall.ENOENT { index-- // usually not found, move up one dir - } else if err == syscall.ENOSPC { + index = int(math.Max(1, float64(index))) + continue + } + + if err == syscall.ENOSPC { // no space left on device, out of inotify watches // TODO: consider letting the user fall back to // polling if they hit this error very often... return fmt.Errorf("Out of inotify watches: %v", err) } else if os.IsPermission(err) { return fmt.Errorf("Permission denied adding a watch: %v", err) - } else { - return fmt.Errorf("Unknown error: %v", err) } - index = int(math.Max(1, float64(index))) - continue + return fmt.Errorf("Unknown error: %v", err) } select {