From f75e264811ab5b2f4bcd5c0fa35a082e2be474f3 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 5 Oct 2021 20:23:17 +0200 Subject: [PATCH] fix: ensure dirs are created Also use debug logging for help. Closes https://git.coopcloud.tech/coop-cloud/organising/issues/183. Closes https://git.coopcloud.tech/coop-cloud/organising/issues/183. --- cli/cli.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index a20013974..557c575ad 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -4,6 +4,7 @@ package cli import ( "fmt" "os" + "path" "coopcloud.tech/abra/cli/app" "coopcloud.tech/abra/cli/catalogue" @@ -82,17 +83,30 @@ func RunApp(version, commit string) { logrus.SetOutput(os.Stderr) logrus.AddHook(logrusStack.StandardHook()) } + + paths := []string{ + config.ABRA_DIR, + path.Join(config.ABRA_DIR, "servers"), + path.Join(config.ABRA_DIR, "apps"), + path.Join(config.ABRA_DIR, "vendor"), + } + + for _, path := range paths { + if err := os.Mkdir(path, 0755); err != nil { + if !os.IsExist(err) { + logrus.Fatal(err) + } + logrus.Debugf("'%s' already created, moving on...", path) + continue + } + logrus.Debugf("'%s' is missing, creating...", path) + } + + logrus.Debugf("abra version '%s', commit '%s'", version, commit) + return nil } - if err := os.Mkdir(config.ABRA_DIR, 0755); err != nil { - if !os.IsExist(err) { - logrus.Fatal(err) - } - } - - logrus.Debugf("abra version '%s', commit '%s'", version, commit) - if err := app.Run(os.Args); err != nil { logrus.Fatal(err) }