Documentation
¶
Overview ¶
Package cachedir owns udf's derived-data directory: a per-user directory inside the operating system's temporary directory, <temp>/ejfkdev/udf.
Everything in it is derived from an input file and can be deleted at any time — a missing entry is rebuilt by the next command that needs it (an image archive index costs one pass, a listing or a metadata file is milliseconds). Keeping it in the temporary directory means the operating system reclaims it on its own terms: macOS purges entries unused for three days, Linux clears /tmp at boot or after ten days. Where the OS does nothing — Windows leaves %TEMP% alone — udf prunes entries itself, on the first write of a run, so the directory cannot grow without bound anywhere.
Layout:
<dir>/*.json small derived values: input class, image metadata,
archive listings, disk metadata, image summaries
<dir>/idx/*.idx random-access indexes for large archives
<dir>/tmp/ per-run scratch (disks decompressed from an OVA/VMA/VM
export); removed by the run that made it, and pruned when
a run is interrupted
The location can be overridden with UDF_CACHE_DIR, which is also how tests keep their cache out of the real one.
Index ¶
Constants ¶
const ( // Env is the environment variable that overrides the directory. Env = "UDF_CACHE_DIR" // CachePruneAge is how long a derived value (a listing, a metadata file, an // index) survives without being rewritten. It is deliberately longer than // the shortest OS purge (three days on macOS) so that pruning only matters // where the OS does not clean up at all. CachePruneAge = 7 * 24 * time.Hour // ScratchPruneAge is how long a scratch directory from an interrupted run // survives. Runs remove their own scratch, so anything this old was left // behind by a crash or a kill. ScratchPruneAge = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
func Dir() string
Dir returns the directory holding udf's derived data. It does not have to exist yet.
func Ensure ¶
func Ensure() string
Ensure creates the directory (and its index subdirectory) and, once per process, prunes entries earlier runs left behind. It returns the directory path, or "" when it cannot be created. The path is read from the environment on every call, so a caller that overrides the location gets that location.
func IndexDir ¶
func IndexDir() string
IndexDir returns the directory holding random-access indexes.
func Prune ¶
Prune removes derived values and scratch left behind by earlier runs. It is best effort: anything it cannot read or remove is ignored, since every entry is expendable.
func ScratchDir ¶
func ScratchDir() string
ScratchDir returns the directory holding per-run scratch files.
Types ¶
This section is empty.