Manager: allow setup to finish without Blender #104306
@ -15,7 +15,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/rs/zerolog"
|
||||
"projects.blender.org/studio/flamenco/internal/appinfo"
|
||||
"projects.blender.org/studio/flamenco/internal/find_blender"
|
||||
"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()
|
||||
|
||||
if setupAssistantCfg.StorageLocation == "" ||
|
||||
isBlenderPathCheckResultIncomplete(setupAssistantCfg.BlenderExecutable, logger) {
|
||||
logger.Warn().Msg("setup assistant: configuration is incomplete, unable to accept")
|
||||
return sendAPIError(e, http.StatusBadRequest, "configuration is incomplete")
|
||||
if err := checkSetupAssistantConfig(setupAssistantCfg); err != nil {
|
||||
logger.Warn().Msg("setup assistant: configuration is invalid or incomplete, " + err.Error())
|
||||
return sendAPIError(e, http.StatusBadRequest, "configuration is invalid or incomplete")
|
||||
}
|
||||
|
||||
conf := f.config.Get()
|
||||
@ -337,28 +335,32 @@ func commandNeedsQuoting(cmd string) bool {
|
||||
return strings.ContainsAny(cmd, "\n\t;()")
|
||||
}
|
||||
|
||||
func isBlenderPathCheckResultIncomplete(checkResult api.BlenderPathCheckResult, logger zerolog.Logger) bool {
|
||||
switch checkResult.Source {
|
||||
case api.BlenderPathSourceDefault:
|
||||
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
|
||||
func checkSetupAssistantConfig(config api.SetupAssistantConfig) error {
|
||||
if config.StorageLocation == "" {
|
||||
return errors.New("'storageLocation' field must not be empty")
|
||||
}
|
||||
|
||||
logger.Warn().Msg("received an unexpected blender path source")
|
||||
return true
|
||||
if !config.BlenderExecutable.IsUsable {
|
||||
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