Documentation
¶
Overview ¶
Package diskprune reclaims explicitly disposable disk data, keeping process references, recent data, symlinks and checkouts intact.
Index ¶
Constants ¶
const CacheMinAge = time.Hour
CacheMinAge protects what a tool may still be writing: no cache unit written within it is removed, whatever its policy says.
Variables ¶
This section is empty.
Functions ¶
func Disposable ¶
Disposable inspects every entry without following symlinks. An unknown directory, checkout, unreadable subtree or recent file is kept.
func InUse ¶
InUse reports whether a candidate contains a live reference, including references reached through a symlink. A reference to a parent alone does not make all its children busy.
Types ¶
type CacheResult ¶ added in v0.173.0
CacheResult is one root's outcome: Held is what it held before, Newest its last write.
func Cache ¶ added in v0.173.0
Cache trims root by p. A root that is a symbolic link, holds a protected path (the home, the state directory, a checkout root) or is itself a checkout is kept whole. A unit a process references, one holding a git checkout (work not yet committed or pushed included) or one written within CacheMinAge is kept; in files mode one reference or checkout inside the root keeps all of it. A dry run measures without writes.
type Policy ¶ added in v0.173.0
type Policy struct {
Root string
Files bool
OlderThan time.Duration
MaxBytes int64
Regenerable bool
// Nested are other policies' roots inside this one: each governs its
// own subtree, which this policy neither counts nor removes.
Nested []string
// Recheck reads the processes' references again once the scan is done
// and before anything is removed; an error keeps the whole root. Nil
// keeps the references the call was given.
Recheck func() ([]string, error)
}
Policy is one cache root's rule. In entries mode the root's direct children are the units, each removed whole; in files mode its regular files. A unit untouched for OlderThan goes; past MaxBytes the least recently written go until the root fits; under pressure a Regenerable cache drops every unit older than CacheMinAge.
type Refs ¶
type Refs struct {
// contains filtered or unexported fields
}
Refs is live references resolved once. A scan asks about every candidate: resolving each reference again per candidate costs candidates x references x path depth syscalls, which kept a dry run going for minutes.
type Result ¶
type Result struct {
Freed int64
Removed int
Moved int64
Staged int
Kept map[string]int
Errors []error
}
Result is one cleanup's measured bytes and keep/error reasons.
func Output ¶
Output reclaims a known output directory, refusing checkouts, active references and data newer than cutoff. A dry run measures without writes.
func Stage ¶
Stage moves build output into trash on the same filesystem. Moving does not free bytes. The new entry starts its retention window now, even when all the output's files are old. Cross-filesystem output is retained.
type Usage ¶
type Usage struct {
Bytes int64
Written time.Time
Checkout bool
// Unreadable says part of the holder could not be read: its size and
// age are a lower bound.
Unreadable bool
}
Usage is what one walk of a holder finds: the space its files take, when anything in it was last written, and whether it holds a git checkout.