From 7292788e7656c638c6b912c759bfa60e35767fb8 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Sat, 22 Jun 2024 19:06:45 +1000 Subject: [PATCH] Sanity check for file updates --- watch.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/watch.go b/watch.go index 24f71c03..269a4636 100644 --- a/watch.go +++ b/watch.go @@ -2,6 +2,7 @@ package main import ( "log" + "os" "path/filepath" "time" @@ -101,6 +102,9 @@ func (watch *watch) loop() { } case <-watch.loadTimer.C: for path := range watch.loads { + if _, err := os.Lstat(path); err != nil { + continue + } dir := newDir(path) dir.sort() watch.dirChan <- dir @@ -108,6 +112,9 @@ func (watch *watch) loop() { watch.loads = make(map[string]bool) case <-watch.updateTimer.C: for path := range watch.updates { + if _, err := os.Lstat(path); err != nil { + continue + } watch.fileChan <- newFile(path) } watch.updates = make(map[string]bool)