safefs

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package safefs provides narrow filesystem primitives for cache publication and repository-contained regular-file rewrites.

Index

Constants

This section is empty.

Variables

View Source
var ErrRepositoryFileTooLarge = errors.New("repository file exceeds read limit")

ErrRepositoryFileTooLarge reports a repository file that exceeds a caller's bounded-read limit.

View Source
var ErrUnsafeRepositoryFile = errors.New("unsafe repository file")

ErrUnsafeRepositoryFile reports a path that cannot safely be read or rewritten as a regular file contained by a repository root.

Functions

func AtomicWriteFile

func AtomicWriteFile(path string, data []byte, perm fs.FileMode) error

AtomicWriteFile publishes data via a unique temporary file and rename. Unique names keep concurrent writers from publishing each other's partial data. Sync bounds torn writes across crashes.

func ReadRepositoryRegularFile

func ReadRepositoryRegularFile(repoRoot, path string) (string, []byte, error)

ReadRepositoryRegularFile reads a regular file contained by repoRoot. It rejects absolute and escaping paths, directories, and symlinks.

func ReadRepositoryRegularFileLimit

func ReadRepositoryRegularFileLimit(repoRoot, path string, maxBytes int64) (string, []byte, error)

ReadRepositoryRegularFileLimit reads at most maxBytes from a regular file contained by repoRoot. It reads one extra byte to detect overflow without allocating the full file.

func RewriteRepositoryRegularFile

func RewriteRepositoryRegularFile(repoRoot, path string, data []byte) error

RewriteRepositoryRegularFile atomically rewrites a regular repository file while preserving its existing permission bits. It validates the target again immediately before publishing the replacement.

Types

This section is empty.

Jump to

Keyboard shortcuts

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