Documentation
¶
Overview ¶
Package diskprune is wb disk prune (spec/features/disk-prune): it removes this user's old scratch from the temporary directory, and clears the Go build cache while no Go process runs. Nothing else is ever deleted.
Index ¶
Constants ¶
const ( CategoryScratch = "scratch" CategoryBuild = "go-build-cache" )
Category names, as --category takes them.
const ( StatusDelete = "delete" StatusDeleted = "deleted" StatusKeep = "keep" StatusSkipped = "skipped" StatusFailed = "failed" )
Statuses of items and categories.
const ( OutcomeDone = "done" OutcomePlanned = "planned" OutcomeSkipped = "skipped" OutcomeFailed = "failed" )
Outcomes of a run.
const DefaultScratchAge = 72 * time.Hour
DefaultScratchAge is how long nothing in a scratch directory may have changed before it is removed: comfortably past any running build or test.
Variables ¶
var Categories = []string{CategoryScratch, CategoryBuild}
Categories are the names --category accepts, in pruning order.
Functions ¶
This section is empty.
Types ¶
type CategoryReport ¶
type CategoryReport struct {
Name string `json:"name"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
// Bytes is what the plan would free, or what apply freed.
Bytes int64 `json:"bytes"`
Items []ItemReport `json:"items,omitempty"`
// Kept counts the directories left alone, by reason.
Kept map[string]int `json:"kept,omitempty"`
}
CategoryReport is one category's plan or result.
type Env ¶
type Env struct {
// TempDirs are the resolved temporary directories (TMPDIR, GOTMPDIR).
TempDirs []string
UID int
Now func() time.Time
// GoCache is the resolved GOCACHE; GoCacheProblem says why there is
// none prune may clear (GOCACHEPROG set, GOCACHE off or missing).
GoCache string
GoCacheProblem string
// GoCacheError is a failure to inspect the Go settings or the cache: a
// finding, unlike a configuration with nothing to clear.
GoCacheError string
// GoCaches are the resolved GOCACHE and GOMODCACHE, which scratch never
// removes even when they sit in the temporary directory.
GoCaches []string
// GoCachesUnknown says why the Go caches could not be located; scratch
// then removes nothing.
GoCachesUnknown string
// MountPoints lists every mount point, so a scratch tree holding a bind
// mount on its own filesystem is kept.
MountPoints func() ([]string, error)
// GoProcesses lists running Go tools, or fails when that cannot be told.
GoProcesses func() ([]Process, error)
// GoClean runs go clean -cache.
GoClean func(ctx context.Context) error
// Measure is the bytes removing path would free.
Measure func(ctx context.Context, path string) int64
// RemoveAll removes a directory tree without following symlinks.
RemoveAll func(path string) error
}
Env is the machine prune works on, as fields so a test can describe any.
type ItemReport ¶
type ItemReport struct {
Path string `json:"path"`
Bytes int64 `json:"bytes"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
ItemReport is one directory the category acts on.
type Options ¶
type Options struct {
Apply bool
// Categories restricts the run; empty means every category.
Categories []string
// ScratchAge is the minimum quiet time of a scratch directory; zero
// means DefaultScratchAge.
ScratchAge time.Duration
}
Options is one invocation's selection.