Fix embed.FS path separator on Windows
Use path.Join (always '/') for embed.FS reads, filepath.Join only for OS paths. filepath.Join on Windows produces backslashes which embed.FS doesn't accept, causing "failed to extract scripts" on startup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c3c8d8e501
commit
f72b4bd190
2 changed files with 7 additions and 4 deletions
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -277,7 +278,8 @@ func ExtractScripts(fs interface{ ReadDir(string) ([]os.DirEntry, error); ReadFi
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
data, err := fs.ReadFile(filepath.Join("scripts", e.Name()))
|
// embed.FS always uses forward slashes regardless of OS
|
||||||
|
data, err := fs.ReadFile(path.Join("scripts", e.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -298,13 +300,14 @@ func extractDir(fs interface{ ReadDir(string) ([]os.DirEntry, error); ReadFile(s
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dst := filepath.Join(dstBase, src)
|
dst := filepath.Join(dstBase, filepath.FromSlash(src))
|
||||||
if err := os.MkdirAll(dst, 0755); err != nil {
|
if err := os.MkdirAll(dst, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
srcPath := filepath.Join(src, e.Name())
|
// embed.FS always uses forward slashes regardless of OS
|
||||||
dstPath := filepath.Join(dstBase, srcPath)
|
srcPath := path.Join(src, e.Name())
|
||||||
|
dstPath := filepath.Join(dstBase, filepath.FromSlash(srcPath))
|
||||||
if e.IsDir() {
|
if e.IsDir() {
|
||||||
if err := extractDir(fs, srcPath, dstBase); err != nil {
|
if err := extractDir(fs, srcPath, dstBase); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
BIN
xetup.exe
BIN
xetup.exe
Binary file not shown.
Loading…
Reference in a new issue