Skip to main content

Module disk

Module disk 

Source
Expand description

Disk accounting: how much magi’s own directories occupy, how much space is left on the volume they live on, and how the shared build cache is pruned.

The whole module grew out of one incident: a machine with 951.8 GB of disk ran a handful of competitions and ended up with 6.7 GB free and a pile of multi-gigabyte target/ directories. Every function here exists to keep that from being a discovery, and every number is substituted at a pure boundary so the policy can be tested without asking the OS anything.

Structs§

Prune
What a prune removed, for the report.

Functions§

dir_size
Total bytes under path, without following symlinks.
enough_space
Are free bytes above the floor for starting a run?
extract_cargo_target_dir
The path a rendered command sets CARGO_TARGET_DIR= to, if any.
free_bytes
Free bytes on the volume containing path.
gate
Why a run must not start, given measured free bytes and the floor — None means the gate is open. Pure, so the policy is asserted directly.
over_limit
Is size past limit? One comparison, shared by the janitor and the health view, so both answer “is the cache over its cap” identically.
parse_df_available
One df -k -P data row: Filesystem 1024-blocks Used Available ….
parse_u64
A bare unsigned integer line, which is all PowerShell prints for a long.
prune_dir
Delete files under dir oldest-first until its size is at or below limit.
volume_root
The volume root of an absolute Windows path, as DriveInfo wants it: C:\, never C:\Users\... and never a verbatim \\?\C:\....