git » chasquid » commit 15b79d9

chasquid-util: Check that we can create the database directory

author Alberto Bertogli
2020-04-13 13:43:51 UTC
committer Alberto Bertogli
2020-04-14 11:01:01 UTC
parent 929a9947bfaaee25bf9a0fb42966ce5357d5ddf6

chasquid-util: Check that we can create the database directory

When creating a database directory, we were missing the check to see if
it had succeeded, which would make issues more difficult to troubleshoot.

This patch adds the missing check.

cmd/chasquid-util/chasquid-util.go +4 -1

diff --git a/cmd/chasquid-util/chasquid-util.go b/cmd/chasquid-util/chasquid-util.go
index ab5eb7c..bc2e707 100644
--- a/cmd/chasquid-util/chasquid-util.go
+++ b/cmd/chasquid-util/chasquid-util.go
@@ -100,7 +100,10 @@ func userDBFromArgs(create bool) (string, string, *userdb.DB) {
 	if err != nil {
 		if create && os.IsNotExist(err) {
 			fmt.Println("Creating database")
-			os.MkdirAll(filepath.Dir(userDBForDomain(domain)), 0755)
+			err = os.MkdirAll(filepath.Dir(userDBForDomain(domain)), 0755)
+			if err != nil {
+				Fatalf("Error creating database dir: %v", err)
+			}
 		} else {
 			Fatalf("Error loading database: %v", err)
 		}