Expand description
safesweep: clean caches and temporary files that are provably safe to delete.
This crate is the library behind the safesweep command-line tool. Its main entry points
are collect, which finds and judges every candidate, and clean::clean, which removes
the ones judged safe. The binary (src/main.rs) is a thin command-line wrapper around them.
§How a run works
rules ──► scan::find ──► scan::measure ──► guard::check ──► Row ──► render / tui / clean
(what) (candidates) (what is in it) (safe? why not?) (one per candidate)rules::RULESlists the locations the tool knows how to clean.scanfinds the candidate paths under each rule and measures them. It only observes.guardturns each measurement into a verdict:ok, or the reason to skip.collectbundles the result as oneRowper candidate, largest first.renderprints the rows,tuilets the user pick from them, andcleanremoves the chosen ones, re-checking each one first.
The separate why module reports what is using the CPU and shares no state with the rest.
See ARCHITECTURE.md in the repository for the design in more detail.
Modules§
- clean
- Removing candidates, and keeping a record of what was removed.
- guard
- The safety guard: the one place that decides whether a candidate may be deleted.
- render
- Turning candidates and sizes into text that is safe to print.
- rules
- The rule table: which locations
safesweepknows how to clean, and the conditions for each. - scan
- Finding candidate paths and measuring them.
- tui
- The interactive explorer behind
safesweep tui. - why
- “What is using my CPU?”: two samples of
/proc, compared. - wsl
- Windows Subsystem for Linux (WSL) support: detecting it, and explaining how to give disk space back to Windows.
Structs§
- Ctx
- Everything about the environment that the tool depends on, gathered in one place.
- Row
- One candidate: the unit that
scanlists, the TUI shows andcleanacts on.
Functions§
- check_
root_ home - Refuses to run as root with a home directory owned by someone else.
- collect
- Finds every candidate of
rules, judges each one, and returns them largest first.