fix: add Windows support for filesystem sync operations

This commit is contained in:
Zach Kelling
2025-12-22 07:56:54 -08:00
parent 6030d8c010
commit 03de0bc797
5 changed files with 27 additions and 5 deletions
+2
View File
@@ -157,3 +157,5 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
)
replace github.com/luxfi/genesis => /Users/z/work/lux/genesis
+2 -3
View File
@@ -17,7 +17,6 @@ import (
"regexp"
"strings"
"sync"
"syscall"
"time"
"github.com/luxfi/crypto/bls"
@@ -967,7 +966,7 @@ func (ln *localNetwork) pauseNode(ctx context.Context, nodeName string) error {
if exitCode != 0 && exitCode != -1 && exitCode != 2 && exitCode != 130 && exitCode != 143 {
return fmt.Errorf("node %q exited with exit code: %d", nodeName, exitCode)
}
syscall.Sync()
syncFilesystem()
node.paused = true
return nil
}
@@ -1092,7 +1091,7 @@ func (ln *localNetwork) restartNode(
if err := ln.removeNode(ctx, nodeName); err != nil {
return err
}
syscall.Sync()
syncFilesystem()
// Wait for ports to be released (TCP TIME_WAIT)
// This prevents "bind: address already in use" errors
+1 -2
View File
@@ -8,7 +8,6 @@ import (
"os"
"path/filepath"
"strings"
"syscall"
"github.com/luxfi/netrunner/api"
"github.com/luxfi/netrunner/network"
@@ -156,7 +155,7 @@ func (ln *localNetwork) SaveSnapshot(ctx context.Context, snapshotName string) (
if err := ln.stop(ctx); err != nil {
return "", err
}
syscall.Sync()
syncFilesystem()
// create main snapshot dirs
snapshotDBDir := filepath.Join(snapshotDir, defaultDBSubdir)
if err := os.MkdirAll(snapshotDBDir, os.ModePerm); err != nil {
+11
View File
@@ -0,0 +1,11 @@
//go:build !windows
// +build !windows
package local
import "syscall"
// syncFilesystem syncs all filesystems on Unix-like systems.
func syncFilesystem() {
syscall.Sync()
}
+11
View File
@@ -0,0 +1,11 @@
//go:build windows
// +build windows
package local
// syncFilesystem is a no-op on Windows.
// Windows doesn't have an equivalent syscall.Sync() function.
// File handles are synced individually via FlushFileBuffers.
func syncFilesystem() {
// No-op on Windows
}