Expand description
Locate build-tool artifact directories across many project types and tell you how much disk space they waste — optionally deleting them.
A project is any directory containing a recognized marker file
(Cargo.toml, package.json, pom.xml, …). Each project has one or more
ProjectTypes, and each type maps to a set of artifact directories
(target, node_modules, build, …) that are safe to delete because the
toolchain will regenerate them.
A single directory may match several project types at once: a Rust + web
project with both Cargo.toml and package.json is {Cargo, Node}, and
Project::artifact_dirs yields the union of their artifact
directories (target + node_modules).
This module performs no destructive actions on its own — you must call
Project::clean explicitly to delete anything.
§Example
use disk_cleaner::projects::{scan, ScanOptions};
let opts = ScanOptions { follow_symlinks: false, same_file_system: false };
for project in scan(&".", &opts).filter_map(Result::ok) {
println!("{} [{}]", project.path.display(), project.type_name());
}Structs§
- Project
- A discovered project: a directory on disk plus the set of project types detected within it.
- Project
Analysis - A project plus the results of analyzing it, produced by
analyze. - Project
Size - A breakdown of a project directory’s disk usage, produced by
Project::size_dirs. - Scan
Options - Options controlling directory traversal, passed to
scananddir_size.
Enums§
- Project
Type - A recognized development-project ecosystem (Cargo, Node, Unity, …).
- Scan
Error - Errors that can occur while scanning a directory tree for projects.
Functions§
- analyze
- Scan
pathfor projects and compute each one’s reclaimable size and last modification time — a streaming convenience overscan+ [project_size_and_mtime]. - clean
- Recursively delete every artifact directory of the project at
project_path. - dir_
size - Total size in bytes of all regular files beneath
path(recursive), traversed with the same options asscan. - scan
- Recursively scan
pathfor projects, yielding each wrapped in aResult.