Manager: allow setup to finish without Blender #104306
@ -182,11 +182,12 @@ func (f *Flamenco) FindBlenderExePath(e echo.Context) error {
|
||||
logger.Warn().AnErr("cause", err).Msg("there was an issue finding Blender")
|
||||
return sendAPIError(e, http.StatusInternalServerError, "there was an issue finding Blender: %v", err)
|
||||
default:
|
||||
isUsable := true
|
||||
response = append(response, api.BlenderPathCheckResult{
|
||||
IsUsable: true,
|
||||
Input: result.Input,
|
||||
Path: result.FoundLocation,
|
||||
Cause: result.BlenderVersion,
|
||||
IsUsable: &isUsable,
|
||||
Input: &result.Input,
|
||||
Path: &result.FoundLocation,
|
||||
Cause: &result.BlenderVersion,
|
||||
Source: result.Source,
|
||||
})
|
||||
}
|
||||
@ -200,11 +201,12 @@ func (f *Flamenco) FindBlenderExePath(e echo.Context) error {
|
||||
case err != nil:
|
||||
logger.Info().AnErr("cause", err).Msg("there was an issue finding Blender as 'blender' on $PATH")
|
||||
default:
|
||||
isUsable := true
|
||||
response = append(response, api.BlenderPathCheckResult{
|
||||
IsUsable: true,
|
||||
Input: result.Input,
|
||||
Path: result.FoundLocation,
|
||||
Cause: result.BlenderVersion,
|
||||
IsUsable: &isUsable,
|
||||
Input: &result.Input,
|
||||
Path: &result.FoundLocation,
|
||||
Cause: &result.BlenderVersion,
|
||||
Source: result.Source,
|
||||
})
|
||||
}
|
||||
@ -223,32 +225,39 @@ func (f *Flamenco) CheckBlenderExePath(e echo.Context) error {
|
||||
}
|
||||
|
||||
command := toCheck.Path
|
||||
var cause string
|
||||
var isUsable bool
|
||||
var path string
|
||||
|
||||
logger = logger.With().Str("command", command).Logger()
|
||||
logger.Info().Msg("checking whether this command leads to Blender")
|
||||
|
||||
ctx := e.Request().Context()
|
||||
checkResult, err := find_blender.CheckBlender(ctx, command)
|
||||
response := api.BlenderPathCheckResult{
|
||||
Input: command,
|
||||
Source: checkResult.Source,
|
||||
Input: &command,
|
||||
Source: checkResult.Source,
|
||||
Path: &path,
|
||||
IsUsable: &isUsable,
|
||||
Cause: &cause,
|
||||
}
|
||||
|
||||
switch {
|
||||
case errors.Is(err, exec.ErrNotFound):
|
||||
response.Cause = "Blender could not be found"
|
||||
*response.Cause = "Blender could not be found"
|
||||
case err != nil:
|
||||
response.Cause = fmt.Sprintf("There was an error running the command: %v", err)
|
||||
*response.Cause = fmt.Sprintf("There was an error running the command: %v", err)
|
||||
default:
|
||||
response.IsUsable = true
|
||||
response.Path = checkResult.FoundLocation
|
||||
response.Cause = fmt.Sprintf("Found %v", checkResult.BlenderVersion)
|
||||
*response.IsUsable = true
|
||||
*response.Path = checkResult.FoundLocation
|
||||
*response.Cause = fmt.Sprintf("Found %v", checkResult.BlenderVersion)
|
||||
}
|
||||
|
||||
logger.Info().
|
||||
Str("input", response.Input).
|
||||
Str("foundLocation", response.Path).
|
||||
Str("result", response.Cause).
|
||||
Bool("isUsable", response.IsUsable).
|
||||
Str("input", *response.Input).
|
||||
Str("foundLocation", *response.Path).
|
||||
Str("result", *response.Cause).
|
||||
Bool("isUsable", *response.IsUsable).
|
||||
Msg("result of command check")
|
||||
|
||||
return e.JSON(http.StatusOK, response)
|
||||
@ -265,11 +274,12 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
|
||||
|
||||
logger = logger.With().Interface("config", setupAssistantCfg).Logger()
|
||||
|
||||
isConfigIncomplete := setupAssistantCfg.StorageLocation == "" ||
|
||||
!setupAssistantCfg.BlenderExecutable.IsUsable ||
|
||||
setupAssistantCfg.BlenderExecutable.Path == ""
|
||||
isConfigIncomplete := setupAssistantCfg.BlenderExecutable.Cause == nil ||
|
||||
setupAssistantCfg.BlenderExecutable.Input == nil ||
|
||||
setupAssistantCfg.BlenderExecutable.IsUsable == nil ||
|
||||
setupAssistantCfg.BlenderExecutable.Path == nil
|
||||
|
||||
if isConfigIncomplete && setupAssistantCfg.BlenderExecutable.Source != "default" {
|
||||
if setupAssistantCfg.BlenderExecutable.Source != "default" && isConfigIncomplete {
|
||||
logger.Warn().Msg("setup assistant: configuration is incomplete, unable to accept")
|
||||
return sendAPIError(e, http.StatusBadRequest, "configuration is incomplete")
|
||||
}
|
||||
@ -286,10 +296,10 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
|
||||
case api.BlenderPathSourcePathEnvvar:
|
||||
// The input command can be found on $PATH, and thus we don't need to save
|
||||
// the absolute path to Blender here.
|
||||
executable = setupAssistantCfg.BlenderExecutable.Input
|
||||
executable = *setupAssistantCfg.BlenderExecutable.Input
|
||||
case api.BlenderPathSourceInputPath:
|
||||
// The path should be used as-is.
|
||||
executable = setupAssistantCfg.BlenderExecutable.Path
|
||||
executable = *setupAssistantCfg.BlenderExecutable.Path
|
||||
}
|
||||
if commandNeedsQuoting(executable) {
|
||||
executable = strconv.Quote(executable)
|
||||
|
Loading…
Reference in New Issue
Block a user