From 7caa0127dcb60e2f6ad8bc9b1fa908c44c8cbfef Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Thu, 10 Apr 2025 17:27:52 +0800 Subject: [PATCH] fix(config): ensure workspace directory is created if it does not exist --- core/utils/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/utils/config.go b/core/utils/config.go index b35ae9e0..c0455681 100644 --- a/core/utils/config.go +++ b/core/utils/config.go @@ -5,6 +5,7 @@ import ( "github.com/gin-gonic/gin" "github.com/mitchellh/go-homedir" "github.com/spf13/viper" + "os" "path/filepath" "strings" ) @@ -92,6 +93,12 @@ func GetWorkspace() string { if res := viper.GetString("workspace"); res != "" { return res } + if !Exists(filepath.Join(homedirPath, DefaultWorkspace)) { + err := os.MkdirAll(filepath.Join(homedirPath, DefaultWorkspace), os.ModePerm) + if err != nil { + logger.Warnf("cannot create workspace directory: %v", err) + } + } return filepath.Join(homedirPath, DefaultWorkspace) }