Skip to main content

Crate safesweep

Crate safesweep 

Source
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)
  1. rules::RULES lists the locations the tool knows how to clean.
  2. scan finds the candidate paths under each rule and measures them. It only observes.
  3. guard turns each measurement into a verdict: ok, or the reason to skip.
  4. collect bundles the result as one Row per candidate, largest first.
  5. render prints the rows, tui lets the user pick from them, and clean removes 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 safesweep knows 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 scan lists, the TUI shows and clean acts 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.