Module gc

Source
Expand description

Support for garbage collecting unused files from downloaded files or artifacts from the target directory.

The Gc type provides the high-level interface for the garbage-collection system.

Garbage collection can be done “automatically” by cargo, which it does by default once a day when running any command that does a lot of work (like cargo build). The entry point for this is the auto_gc function, which handles some basic setup, creating the Gc, and calling Gc::auto.

Garbage collection can also be done manually via the cargo clean command by passing any option that requests deleting unused files. That is implemented by calling the Gc::gc method.

Garbage collection for the global cache is guided by the last-use tracking implemented in the crate::core::global_cache_tracker module. See that module documentation for an in-depth explanation of how global cache tracking works.

Structs§

AutoConfig 🔒
Automatic garbage collection settings from the gc.auto config table.
Gc
Garbage collector.
GcOpts
Options to use for garbage collection.

Constants§

DEFAULT_AUTO_FREQUENCY 🔒
How often auto-gc will run by default unless overridden in the config.
DEFAULT_MAX_AGE_DOWNLOADED 🔒
Default max ago to auto-clean cache data, which must be downloaded to recover.
DEFAULT_MAX_AGE_EXTRACTED 🔒
Default max age to auto-clean extracted sources, which can be recovered without downloading anything.

Functions§

auto_gc
Performs automatic garbage collection.
auto_gc_inner 🔒
maybe_newer_span 🔒
Returns whichever Duration is shorter.
maybe_parse_time_span 🔒
Parses a time span string.
newer_time_span_for_config 🔒
Returns the shorter duration from cur_span versus config_span.
parse_frequency 🔒
Parses a frequency string.
parse_human_size
Parses a file size using metric or IEC units.
parse_time_span
Parses a time span string.
parse_time_span_for_config 🔒
Parses a time span value fetched from config.