Files
ThothII/tools/thothctl/internal/pi/durable_unix.go
T

16 lines
455 B
Go

//go:build !windows
package pi
import "os"
// durableReplace acknowledges both the data file and its directory entry. A successful return
// is the strongest atomic replacement guarantee supported by Unix filesystems.
func durableReplace(temporary, target, directory string) error {
if err := os.Rename(temporary, target); err != nil { return err }
dir, err := os.Open(directory)
if err != nil { return err }
defer dir.Close()
return dir.Sync()
}