Skip to content
Permalink
Browse files

require storage directory to exist, instead of creating

It's less surprising behavior to get an error that the storage
directory does not exist, instead of it being created automatically.
  • Loading branch information...
dmitshur committed Jun 22, 2019
1 parent 5476705 commit 7d16d0355c5f10565b900d06c4141f0da44ce0cc
Showing with 6 additions and 3 deletions.
  1. +6 −3 main.go
@@ -32,9 +32,12 @@ func main() {
var localStore webdav.FileSystem
switch *storageDirFlag {
default:
err := os.MkdirAll(*storageDirFlag, 0755)
if err != nil {
log.Fatalf("error creating directory %q: %v", *storageDirFlag, err)
if fi, err := os.Stat(*storageDirFlag); os.IsNotExist(err) {
log.Fatalf("storage directory %q doesn't exist: %v", *storageDirFlag, err)
} else if err != nil {
log.Fatalf("error doing stat of directory %q: %v", *storageDirFlag, err)
} else if !fi.IsDir() {
log.Fatalf("file %q is not a directory", *storageDirFlag)
}
localStore = webdav.Dir(*storageDirFlag)
case "":

0 comments on commit 7d16d03

Please sign in to comment.
You can’t perform that action at this time.