Sanity check destinations

This commit is contained in:
2022-04-09 23:42:38 +09:30
parent 4f33603a0c
commit f899b9c0c2
2 changed files with 15 additions and 3 deletions

View File

@@ -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
}