steady

package
v0.1.1168 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package steady reads and replaces files that another process may be replacing at that moment. On Windows a file being renamed over refuses to open, and one held open refuses to be renamed over, both for a moment ("Access is denied"): read as none, a file of accounts is no accounts, and the next write leaves them out. A file being renamed over is also, for a moment (two milliseconds seen), not there at all, to another process or thread: Stat and ReadThere wait that out for a file that was there. Elsewhere a rename is atomic and these are os.Stat, os.ReadFile and os.Rename.

Index

Constants

This section is empty.

Variables

View Source
var Sync = (*os.File).Sync

Sync is (*os.File).Sync; a test stands in for it to make a flush fail.

Functions

func ReadFile

func ReadFile(p string) ([]byte, error)

ReadFile is os.ReadFile, waiting out a file being replaced.

func ReadThere added in v0.1.945

func ReadThere(p string) ([]byte, error)

ReadThere is ReadFile of a file just found there (Stat): not there now is it being replaced, waited out.

func Rename

func Rename(oldpath, newpath string) error

Rename is os.Rename, waiting out a reader holding newpath open.

func Stat added in v0.1.945

func Stat(p string) (fs.FileInfo, error)

Stat is os.Stat of a file that was there: one being replaced is waited for, so it isn't taken for gone. A file not there costs the wait, so a caller asking again remembers it gone (filememo does).

func WriteFile added in v0.1.1166

func WriteFile(p string, b []byte, perm fs.FileMode) error

WriteFile replaces p with b, mode perm, through a temp file beside it that is flushed to the disk before it is renamed over p. A rename reaches the disk on its own schedule and the data behind it later: a Windows machine that went down between the two left logins.json and plugin-auth.json at their full length with every byte zero (#1505). A write or flush that fails removes the temp file and leaves p as it was.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL