From 8e97f4ff617cb7c6ab3ba66db4e69ab81c096636 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 13 Jan 2021 21:38:57 +0100 Subject: [PATCH] confwatcher: fail if configuration file doesn't exist --- internal/confwatcher/confwatcher.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/confwatcher/confwatcher.go b/internal/confwatcher/confwatcher.go index 23b4c1fb..752dfbff 100644 --- a/internal/confwatcher/confwatcher.go +++ b/internal/confwatcher/confwatcher.go @@ -1,6 +1,7 @@ package confwatcher import ( + "os" "path/filepath" "time" @@ -24,12 +25,16 @@ type ConfWatcher struct { // New allocates a ConfWatcher. func New(confPath string) (*ConfWatcher, error) { + if _, err := os.Stat(confPath); err != nil { + return nil, err + } + inner, err := fsnotify.NewWatcher() if err != nil { return nil, err } - // use absolute path to support Darwin + // use absolute paths to support Darwin absolutePath, _ := filepath.Abs(confPath) parentPath := filepath.Dir(absolutePath)