diff --git a/internal/find_blender/find_blender.go b/internal/find_blender/find_blender.go index 9098de72..43126e62 100644 --- a/internal/find_blender/find_blender.go +++ b/internal/find_blender/find_blender.go @@ -6,7 +6,9 @@ import ( "context" "errors" "fmt" + "os" "os/exec" + "path/filepath" "strings" "time" @@ -58,8 +60,8 @@ func CheckBlender(ctx context.Context, exename string) (CheckBlenderResult, erro } if crosspath.Dir(exename) != "." { - // exename is some form of path, see if it works directly as executable. - return getResultWithVersion(ctx, exename, exename, api.BlenderPathSourceInputPath) + // exename is some form of path, see if it works for us. + return checkBlenderAtPath(ctx, exename) } // Try to find exename on $PATH @@ -70,6 +72,25 @@ func CheckBlender(ctx context.Context, exename string) (CheckBlenderResult, erro return getResultWithVersion(ctx, exename, fullPath, api.BlenderPathSourcePathEnvvar) } +func checkBlenderAtPath(ctx context.Context, path string) (CheckBlenderResult, error) { + stat, err := os.Stat(path) + if err != nil { + return CheckBlenderResult{}, err + } + if !stat.IsDir() { + // Simple case, it's not a directory so let's just try and execute it. + return getResultWithVersion(ctx, path, path, api.BlenderPathSourceInputPath) + } + + // Try appending the Blender executable name. + log.Debug(). + Str("path", path). + Str("executable", blenderExeName). + Msg("blender finder: given path is directory, going to find Blender executable") + exepath := filepath.Join(path, blenderExeName) + return getResultWithVersion(ctx, path, exepath, api.BlenderPathSourceInputPath) +} + // getResultWithVersion tries to run the command to get Blender's version. // The result is returned as a `CheckBlenderResult` struct. func getResultWithVersion( diff --git a/internal/find_blender/nonwindows.go b/internal/find_blender/nonwindows.go index 2c6b59b9..43d45f72 100644 --- a/internal/find_blender/nonwindows.go +++ b/internal/find_blender/nonwindows.go @@ -4,6 +4,8 @@ package find_blender // SPDX-License-Identifier: GPL-3.0-or-later +const blenderExeName = "blender" + // fileAssociation isn't implemented on non-Windows platforms. func fileAssociation() (string, error) { return "", ErrNotAvailable diff --git a/internal/find_blender/windows.go b/internal/find_blender/windows.go index 0fede474..6549c35b 100644 --- a/internal/find_blender/windows.go +++ b/internal/find_blender/windows.go @@ -14,6 +14,8 @@ import ( "unsafe" ) +const blenderExeName = "blender.exe" + // fileAssociation returns the full path of `blender.exe` associated with ".blend" files. func fileAssociation() (string, error) { exe, err := getFileAssociation(".blend") diff --git a/web/app/src/views/SetupAssistantView.vue b/web/app/src/views/SetupAssistantView.vue index e1b942f4..0e99e1f8 100644 --- a/web/app/src/views/SetupAssistantView.vue +++ b/web/app/src/views/SetupAssistantView.vue @@ -182,7 +182,7 @@ v-model="customBlenderExe" :class="{'is-invalid': blenderExeCheckResult != null && !blenderExeCheckResult.is_usable}" type="text" - placeholder="Path to Blender executable" + placeholder="Path to Blender" >
Checking...