From e67f8b4d692e9301469d9cfc6e8ac62672943028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Scha=CC=88fer?= <101886095+PeterSchafer@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:36:50 +0100 Subject: [PATCH] fix: check if cachedir is empty --- cliv2/cmd/cliv2/main.go | 2 ++ cliv2/internal/cliv2/cliv2.go | 12 +++++++----- cliv2/pkg/basic_workflows/legacycli.go | 2 -- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cliv2/cmd/cliv2/main.go b/cliv2/cmd/cliv2/main.go index eb33316b05..d805c51026 100644 --- a/cliv2/cmd/cliv2/main.go +++ b/cliv2/cmd/cliv2/main.go @@ -235,6 +235,8 @@ func MainWithErrorCode() int { debugLogger.Println("Organization:", config.GetString(configuration.ORGANIZATION)) debugLogger.Println("API:", config.GetString(configuration.API_URL)) + debugLogger.Println("Cache directory:", config.GetString(configuration.CACHE_PATH)) + debugLogger.Println("Insecure HTTPS:", config.GetBool(configuration.INSECURE_HTTPS)) // init NetworkAccess networkAccess := engine.GetNetworkAccess() diff --git a/cliv2/internal/cliv2/cliv2.go b/cliv2/internal/cliv2/cliv2.go index 6e5bb67524..f2e4d34eb3 100644 --- a/cliv2/internal/cliv2/cliv2.go +++ b/cliv2/internal/cliv2/cliv2.go @@ -70,11 +70,13 @@ func NewCLIv2(cacheDirectory string, debugLogger *log.Logger) (*CLI, error) { func (c *CLI) Init() (err error) { c.DebugLogger.Println("Init start") - // ensure the specified base cache directory exists, this needs to be done even before acquiring the lock - if _, err = os.Stat(c.CacheDirectory); os.IsNotExist(err) { - err = os.Mkdir(c.CacheDirectory, local_utils.CACHEDIR_PERMISSION) - if err != nil { - return err + if len(c.CacheDirectory) > 0 { + // ensure the specified base cache directory exists, this needs to be done even before acquiring the lock + if _, err = os.Stat(c.CacheDirectory); os.IsNotExist(err) { + err = os.Mkdir(c.CacheDirectory, local_utils.CACHEDIR_PERMISSION) + if err != nil { + return err + } } } diff --git a/cliv2/pkg/basic_workflows/legacycli.go b/cliv2/pkg/basic_workflows/legacycli.go index b45c18c66b..d2ac3e361c 100644 --- a/cliv2/pkg/basic_workflows/legacycli.go +++ b/cliv2/pkg/basic_workflows/legacycli.go @@ -64,8 +64,6 @@ func legacycliWorkflow(invocation workflow.InvocationContext, input []workflow.D } debugLogger.Println("Arguments:", args) - debugLogger.Println("Cache directory:", cacheDirectory) - debugLogger.Println("Insecure HTTPS:", insecure) debugLogger.Println("Use StdIO:", useStdIo) // init cli object