From f899b9c0c250141c79b3c58dbc51285712a9bef3 Mon Sep 17 00:00:00 2001
From: Justin Hawkins
Date: Sat, 9 Apr 2022 23:42:38 +0930
Subject: [PATCH] Sanity check destinations
---
config/config.go | 11 +++++++++++
web/config.html | 7 ++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/config/config.go b/config/config.go
index 238bc67..137b7f4 100644
--- a/config/config.go
+++ b/config/config.go
@@ -175,6 +175,17 @@ func (c *Config) UpdateFromJSON(j []byte) error {
}
}
+ // check destinations
+ for _, dest := range newConfig.Destinations {
+ s, err := os.Stat(dest.Path)
+ if err != nil {
+ return fmt.Errorf("destination '%s' (%s) is bad: %s", dest.Name, dest.Path, err)
+ }
+ if !s.IsDir() {
+ return fmt.Errorf("destination '%s' (%s) is not a directory", dest.Name, dest.Path)
+ }
+ }
+
*c = newConfig
return nil
}
diff --git a/web/config.html b/web/config.html
index 1c5e8cd..72be425 100644
--- a/web/config.html
+++ b/web/config.html
@@ -114,8 +114,9 @@
@@ -137,7 +138,7 @@
-
+