Move "blender finder" from Worker-specific to common location

Manager's first-time wizard will have to be able to find Blender as well.
This commit is contained in:
Sybren A. Stüvel 2022-07-12 14:39:30 +02:00
parent aa9837b5f0
commit 20f13257f7
7 changed files with 36 additions and 17 deletions

View File

@ -0,0 +1,14 @@
package find_blender
// SPDX-License-Identifier: GPL-3.0-or-later
import "errors"
var ErrNotAvailable = errors.New("not available on this platform")
// FindBlender returns the full path of a Blender executable.
// `ErrNotAvailable` is returned if no "blender finder" is available for the current platform.
func FindBlender() (string, error) {
// findBlender() is implemented in one of the platform-dependent files.
return findBlender()
}

View File

@ -0,0 +1,10 @@
//go:build !windows
package find_blender
// SPDX-License-Identifier: GPL-3.0-or-later
// findBlender returns ErrNotAvailable, as the file association lookup is only available on Windows.
func findBlender() (string, error) {
return "", ErrNotAvailable
}

View File

@ -1,8 +1,9 @@
//go:build windows
// SPDX-License-Identifier: GPL-3.0-or-later
package find_blender
// SPDX-License-Identifier: GPL-3.0-or-later
import (
"errors"
"fmt"
@ -13,8 +14,8 @@ import (
"unsafe"
)
// FindBlender returns the full path of `blender.exe` associated with ".blend" files.
func FindBlender() (string, error) {
// findBlender returns the full path of `blender.exe` associated with ".blend" files.
func findBlender() (string, error) {
exe, err := fileAssociation(".blend")
if err != nil {
return "", err

View File

@ -1,8 +1,9 @@
//go:build windows
// SPDX-License-Identifier: GPL-3.0-or-later
package find_blender
// SPDX-License-Identifier: GPL-3.0-or-later
import (
"flag"
"testing"
@ -15,7 +16,7 @@ var withBlender = flag.Bool("withBlender", false, "run test that requires Blende
// TestFindBlender is a "weak" test, which actually accepts both happy and unhappy flows.
// It would be too fragile to always require a file association to be set up with Blender.
func TestFindBlender(t *testing.T) {
exe, err := FindBlender()
exe, err := findBlender()
if err != nil {
assert.Empty(t, exe)

View File

@ -16,7 +16,7 @@ import (
"github.com/google/shlex"
"github.com/rs/zerolog"
"git.blender.org/flamenco/internal/worker/find_blender"
"git.blender.org/flamenco/internal/find_blender"
"git.blender.org/flamenco/pkg/api"
)

View File

@ -1,11 +0,0 @@
//go:build !windows
// SPDX-License-Identifier: GPL-3.0-or-later
package find_blender
import "errors"
// FindBlender returns an error, as the file association lookup is only available on Windows.
func FindBlender() (string, error) {
return "", errors.New("file association lookup is only available on Windows")
}

View File

@ -27,6 +27,10 @@
{{ sharedStorageCheckResult.cause }}
</p>
</section>
<section>
<h2>Which Blender?</h2>
</section>
</div>
<footer class="app-footer">