privatefile

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package privatefile updates small owner-private files by atomic replacement.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigurationChanged = errors.New("Configuration changed while this command was running; no changes were made. Review the file and retry.")

ErrConfigurationChanged is the published retryable outcome for an accidental concurrent edit detected before replacement.

Functions

func Preflight

func Preflight(path, conventionalPath string, maxBytes int64, validate func([]byte) error) error

Preflight validates the private parent and target, then calls validate for an existing target. conventionalPath may name the one target whose missing parent directory may later be created by Update.

func Supported

func Supported() bool

Supported reports whether preserving private-file updates are implemented.

Types

type CommitState

type CommitState string

CommitState describes how far a preserving update progressed.

const (
	// CommitNoop means the requested value already held.
	CommitNoop CommitState = "no_op"
	// CommitNotApplied means replacement did not occur.
	CommitNotApplied CommitState = "not_applied"
	// CommitDurable means replacement and parent sync succeeded.
	CommitDurable CommitState = "durable"
	// CommitReplacementAppliedDurabilityUnknown means replacement occurred but a later durability step failed.
	CommitReplacementAppliedDurabilityUnknown CommitState = "replacement_applied_durability_unknown"
)

func Update

func Update(ctx context.Context, path, conventionalPath string, maxBytes int64, mutate Mutate) (CommitState, error)

Update performs a bounded preserving update. Its second read is best-effort detection of accidental concurrent edits, not a CAS against a hostile same-UID process. conventionalPath may name the one target whose missing 0700 parent directory may be created.

type Mutate

type Mutate func([]byte) (out []byte, noop bool, err error)

Mutate returns the preserving replacement and whether the file is unchanged.

Jump to

Keyboard shortcuts

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