volume

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package volume provides bounded snapshot and restore mechanics for a caller-selected local volume or directory. Identity, authorization, retention, and transport policy belong to the caller.

Index

Constants

View Source
const (
	// DefaultMaxEntries bounds the files and directories removal may traverse.
	DefaultMaxEntries = 10_000
	// MaxEntries is the library ceiling for MaxEntries.
	MaxEntries = 1_000_000
	// DefaultMaxBytes bounds the content bytes removal may traverse.
	DefaultMaxBytes int64 = 1 << 30
	// MaxBytes is the library ceiling for MaxBytes.
	MaxBytes int64 = 1 << 40
	// DefaultMaxDepth bounds the number of directory components a path may add.
	DefaultMaxDepth = 32
	// MaxDepth is the library ceiling for MaxDepth.
	MaxDepth = 128
)

Variables

View Source
var (
	// ErrUnsafePath reports a link, reparse point, non-directory, or broad
	// target the caller did not intend to create or delete.
	ErrUnsafePath = errors.New("unsafe private volume path")
	// ErrStale reports a volume whose native identity no longer matches the
	// inspected directory.
	ErrStale = errors.New("private volume identity changed")
	// ErrLimit reports content beyond a caller-selected creation or removal
	// bound.
	ErrLimit = errors.New("private volume limit exceeded")
	// ErrInvalid reports a malformed path or volume value.
	ErrInvalid = errors.New("invalid private volume")
)

Functions

func RemovePrivate

func RemovePrivate(ctx context.Context, volume PrivateVolume, limits PrivateLimits) error

RemovePrivate removes exactly the inspected directory after revalidating its native identity and bounded contents. It refuses links, reparse points, broad targets, and a directory replaced since inspection. The caller supplies the traversal bounds and authorizes deletion; the library does neither.

Types

type PrivateLimits

type PrivateLimits struct {
	MaxEntries int
	MaxBytes   int64
	MaxDepth   int
}

PrivateLimits bound creation and removal. Zero values select the defaults.

type PrivateVolume

type PrivateVolume struct {
	Path     string
	Identity string
	Created  bool
	Entries  int
	Bytes    int64
	// contains filtered or unexported fields
}

PrivateVolume is an inspected, caller-selected private directory. Identity is an opaque digest for reporting; native same-file checks pin the handle. A PrivateVolume is only usable for removal when produced by InspectPrivate or CreatePrivate.

func CreatePrivate

func CreatePrivate(ctx context.Context, path string, limits PrivateLimits) (PrivateVolume, error)

CreatePrivate creates a caller-selected private directory with 0700 permissions and missing parents. The library never selects the path and never authorizes deletion; the caller does both.

func InspectPrivate

func InspectPrivate(ctx context.Context, path string, limits PrivateLimits) (PrivateVolume, error)

InspectPrivate validates and counts an existing private directory without following links. It refuses a directory readable or writable by another user.

Jump to

Keyboard shortcuts

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