Sanity check for file updates

This commit is contained in:
Joe Lim committed 2024-06-22 19:06:45 +10:00
1 parent c2879498a2
commit 7292788e76
1 file changed
+7
+7
View File
@@ -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)