mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
fix(config): ensure workspace directory is created if it does not exist
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user