Skip to content

Commit 42694cb

Browse files
committed
added auto update check and update as user wish
1 parent e6c16c6 commit 42694cb

2 files changed

Lines changed: 457 additions & 1 deletion

File tree

Apps/node_runner/main.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,27 @@ func downloadFile(url, destPath string) error {
5252
}
5353
}
5454

55-
// Move the temp file to the destination
55+
// Move the temp file to the destination (on Windows, rename can't cross drives)
5656
if err := os.Rename(out.Name(), destPath); err != nil {
57+
if runtime.GOOS == "windows" {
58+
// Cross-device rename failed, use copy instead
59+
src, err := os.Open(out.Name())
60+
if err != nil {
61+
return fmt.Errorf("failed to open temp file: %v", err)
62+
}
63+
defer src.Close()
64+
65+
dst, err := os.Create(destPath)
66+
if err != nil {
67+
return fmt.Errorf("failed to create destination: %v", err)
68+
}
69+
defer dst.Close()
70+
71+
if _, err := io.Copy(dst, src); err != nil {
72+
return fmt.Errorf("failed to copy file: %v", err)
73+
}
74+
return nil
75+
}
5776
return fmt.Errorf("failed to move file to destination: %v", err)
5877
}
5978

@@ -274,6 +293,11 @@ func main() {
274293

275294
fmt.Printf("✅ ZeuZ Node %s\n", version)
276295

296+
// Check for updates (non-blocking, uses cached info from last run)
297+
if !HandleUpdateFlow() {
298+
return
299+
}
300+
277301
zeuzDir := getZeuZNodeDir()
278302

279303
if *cleanFlag {

0 commit comments

Comments
 (0)