file

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SnapshotNameMaxLabel = 20

SnapshotNameMaxLabel caps the human-readable label in a staging dir name. The label is operator convenience only; uniqueness comes from the appended hash, not the label.

Variables

This section is empty.

Functions

func CopyFile added in v1.38.3

func CopyFile(src, dst string) (err error)

CopyFile copies src to dst with an independent inode — unlike a hardlink, later writes to src can't corrupt dst. The destination is fsynced.

NOTE: not atomic (in-place write, no temp+rename), so a crash mid-copy can leave a partial dst. Does not create dst's parent directory.

func HardlinkFiles added in v1.38.3

func HardlinkFiles(pairs []HardlinkPair) error

HardlinkFiles hardlinks each pair, creating Dst's parent directories as needed.

The caller must keep the Src files stable for the call (e.g. by halting the shard) and pass only immutable files: a shared inode would let post-snapshot writes corrupt the staged copy. Use CopyFile for mutable files.

func ProbeHardlinkSupport added in v1.38.3

func ProbeHardlinkSupport(dir string) bool

ProbeHardlinkSupport reports whether the filesystem backing dir supports hardlinks.

func SafeStagingDirName added in v1.38.3

func SafeStagingDirName(prefix string, parts ...string) string

SafeStagingDirName builds a staging directory name guaranteed to fit within filesystem path-component limits (255 bytes) regardless of input length, while staying unique via a hash suffix of the full input.

Example: SafeStagingDirName(".backup-staging-", "backup1", "myclass") → ".backup-staging-backup1-myclass-a1b2c3d4e5f6"

Types

type FileMetadata

type FileMetadata struct {
	Name  string `json:"name"`
	Size  int64  `json:"size"`
	CRC32 uint32 `json:"crc32"`
}

func GetFileMetadata

func GetFileMetadata(filePath string) (FileMetadata, error)

type HardlinkPair added in v1.38.3

type HardlinkPair struct {
	Src string
	Dst string
}

HardlinkPair is one src→dst hardlink request; both are absolute paths.

Jump to

Keyboard shortcuts

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