Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,25 @@ jobs:

- name: Test
run: cargo xtask test

macos:
name: Lint and test (macOS)
# Apple silicon. GPUI draws with Metal here, so no system libraries are
# needed; the core tests also exercise getfsstat, firmlinks and the
# Finder's Trash against the runner's real volumes.
runs-on: macos-15
steps:
- uses: actions/checkout@v5

- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.97"
components: clippy, rustfmt

- uses: Swatinem/rust-cache@v2

- name: Lint
run: cargo xtask lint

- name: Test
run: cargo xtask test
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ going in; `0` resets.
there, then choose:

- **Move to trash** — the default when a trash is available (`trash-put` from
trash-cli, then `gio trash`, then a built-in XDG trash). Recoverable until
trash-cli, then `gio trash`, then a built-in XDG trash; on macOS, the
Finder's Trash, so Put Back works). Recoverable until
the trash is emptied, so it commits directly.
- **Delete permanently** — `rm -rf` semantics. It always asks first, in a dialog
that names what goes and how much comes back.
Expand Down Expand Up @@ -192,10 +193,32 @@ tested:
filesystem;
- system trees (`/usr`, `/etc`, `/boot`, `/var/lib`, `/nix/store`, …) are
refused even where permissions would allow it: packages own them, and
pacman, paccache or `journalctl --vacuum` are the tools;
pacman, paccache or `journalctl --vacuum` are the tools. On macOS the same
goes for `/System`, `/Library`, `/private/etc`, `/private/var/db`,
`/private/var/vm` and `/opt/homebrew`, through either face of a firmlink;
- a symlink is unlinked, never followed;
- nothing is passed through a shell — a file called `-rf` is just a file.

## On macOS

disktree builds and runs on macOS (Apple silicon or Intel) with `cargo build
--release`; GPUI draws with Metal, so nothing else is needed. The Omarchy
theme falls back to its defaults. What differs underneath:

- **The whole disk is `/`.** Your files live on the Data volume, mounted at
`/System/Volumes/Data` and shown again at `/Users`, `/Applications` and so
on through firmlinks. `g` and `--disk` scan `/` and leave the Data volume's
own mount point out, so the sealed system and every user file are each
counted once.
- **The mount table comes from `getfsstat`,** without waiting on any
filesystem, so a mounted SMB or NFS share that has gone away cannot stall
a scan, and is never entered.
- **Free space counts purgeable space,** the figure the Finder and System
Settings show: caches, local Time Machine snapshots and iCloud files the
system drops on demand. It can be well above what `df` reports.
- **Trash is the Finder's Trash.** A removal to the trash frees nothing until
the Trash is emptied; the summary says so.

## On Hyprland

Hyprland tiles new windows, so disktree opens into whatever tile it is given.
Expand Down
16 changes: 16 additions & 0 deletions crates/disktree-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,21 @@ rayon = { workspace = true }
rustix = { version = "1.1", features = ["fs"] }
rustc-hash = { workspace = true }

# The mount table, the Finder's Trash and purgeable space; see `macos.rs`.
# All three are already in the graph through GPUI, so this adds no crates.
[target.'cfg(target_os = "macos")'.dependencies]
libc = "0.2"
objc2 = "0.6"
objc2-foundation = { version = "0.3", default-features = false, features = [
"std",
"NSArray",
"NSDictionary",
"NSError",
"NSFileManager",
"NSString",
"NSURL",
"NSValue",
] }

[dev-dependencies]
tempfile = "3"
2 changes: 2 additions & 0 deletions crates/disktree-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
pub mod classify;
pub mod filter;
pub mod insights;
#[cfg(target_os = "macos")]
pub mod macos;
pub mod removal;
pub mod scan;
pub mod size;
Expand Down
Loading