diff --git a/launcher/beatmapdirwatcher.go b/launcher/beatmapdirwatcher.go index c83e432b..845068d8 100644 --- a/launcher/beatmapdirwatcher.go +++ b/launcher/beatmapdirwatcher.go @@ -4,6 +4,7 @@ import ( "github.com/fsnotify/fsnotify" "github.com/wieku/danser-go/framework/goroutines" "log" + "os" "path/filepath" ) @@ -12,6 +13,13 @@ var watcher *fsnotify.Watcher func setupWatcher(file string, callback func(event fsnotify.Event)) { var err error + abs, _ := filepath.Abs(file) + + _, err1 := os.Lstat(abs) + if err1 != nil { // Beatmap dir not found, abort + return + } + watcher, err = fsnotify.NewWatcher() if err != nil { log.Fatal(err) @@ -39,8 +47,6 @@ func setupWatcher(file string, callback func(event fsnotify.Event)) { } }) - abs, _ := filepath.Abs(file) - err = watcher.Add(abs) if err != nil { log.Fatal(err)