Manager: allow setup to finish without Blender #104306
@ -15,7 +15,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/rs/zerolog"
|
|
||||||
"projects.blender.org/studio/flamenco/internal/appinfo"
|
"projects.blender.org/studio/flamenco/internal/appinfo"
|
||||||
"projects.blender.org/studio/flamenco/internal/find_blender"
|
"projects.blender.org/studio/flamenco/internal/find_blender"
|
||||||
"projects.blender.org/studio/flamenco/internal/manager/config"
|
"projects.blender.org/studio/flamenco/internal/manager/config"
|
||||||
@ -266,10 +265,9 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
|
|||||||
|
|
||||||
logger = logger.With().Interface("config", setupAssistantCfg).Logger()
|
logger = logger.With().Interface("config", setupAssistantCfg).Logger()
|
||||||
|
|
||||||
if setupAssistantCfg.StorageLocation == "" ||
|
if err := checkSetupAssistantConfig(setupAssistantCfg); err != nil {
|
||||||
isBlenderPathCheckResultIncomplete(setupAssistantCfg.BlenderExecutable, logger) {
|
logger.Warn().Msg("setup assistant: configuration is invalid or incomplete, " + err.Error())
|
||||||
logger.Warn().Msg("setup assistant: configuration is incomplete, unable to accept")
|
return sendAPIError(e, http.StatusBadRequest, "configuration is invalid or incomplete")
|
||||||
return sendAPIError(e, http.StatusBadRequest, "configuration is incomplete")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := f.config.Get()
|
conf := f.config.Get()
|
||||||
@ -337,28 +335,32 @@ func commandNeedsQuoting(cmd string) bool {
|
|||||||
return strings.ContainsAny(cmd, "\n\t;()")
|
return strings.ContainsAny(cmd, "\n\t;()")
|
||||||
}
|
}
|
||||||
|
|
||||||
func isBlenderPathCheckResultIncomplete(checkResult api.BlenderPathCheckResult, logger zerolog.Logger) bool {
|
func checkSetupAssistantConfig(config api.SetupAssistantConfig) error {
|
||||||
switch checkResult.Source {
|
if config.StorageLocation == "" {
|
||||||
case api.BlenderPathSourceDefault:
|
return errors.New("'storageLocation' field must not be empty")
|
||||||
if !checkResult.IsUsable {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
case api.BlenderPathSourceFileAssociation:
|
|
||||||
if !checkResult.IsUsable ||
|
|
||||||
checkResult.Path == "" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
case api.BlenderPathSourceInputPath, api.BlenderPathSourcePathEnvvar:
|
|
||||||
if !checkResult.IsUsable ||
|
|
||||||
checkResult.Path == "" ||
|
|
||||||
checkResult.Input == "" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Warn().Msg("received an unexpected blender path source")
|
if !config.BlenderExecutable.IsUsable {
|
||||||
return true
|
return errors.New("sources cannot have the 'is_usable' field set to false")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch config.BlenderExecutable.Source {
|
||||||
|
case api.BlenderPathSourceDefault:
|
||||||
|
return nil
|
||||||
|
|
||||||
|
case api.BlenderPathSourceFileAssociation:
|
||||||
|
if config.BlenderExecutable.Path == "" {
|
||||||
|
return errors.New("'path' field must not be empty while using the 'file_association' source")
|
||||||
|
}
|
||||||
|
|
||||||
|
case api.BlenderPathSourceInputPath, api.BlenderPathSourcePathEnvvar:
|
||||||
|
if config.BlenderExecutable.Path == "" ||
|
||||||
|
config.BlenderExecutable.Input == "" {
|
||||||
|
return errors.New("'path' or 'input' fields must not be empty while using the 'input_path' or 'path_envvar' sources")
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return errors.New("unknown 'source' field value: " + string(config.BlenderExecutable.Source))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user