Commit Graph
47 Commits
Author SHA1 Message Date
Tobi Lutke d2cbab6468 app: explore SSH scans read-only and export host-guarded cleanup 2026-10-22 16:22:26 -04:00
Tobi Lutke 48b0284fa7 core: add read-only SSH scanner and checked helper deployment 2026-10-22 16:13:43 -04:00
Tobi LütkeandClaude Opus 5.5 fcb627634f Keep a snapshot-booted root's subvolumes, and stat directories on macOS
The projection from #56 tested the scanned mount for being a snapshot as
well as the other one. On a system booted from a Snapper snapshot, as
openSUSE is by default, `/` is one, so every mark under `/var` or `/home`
was called another volume's although the scan walks them as its own.
Only the other mount is tested now, as `foreign_mounts` does.

The bulk listing from #53 is thought to report a mount point with the
attributes of the directory it covers, so its device would be the parent
volume's and the walk would cross into every disk, share and system
volume below the root. Directories are stated with `statat` again, as
`lstat` did before; files keep the bulk path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 17:05:04 +00:00
Tobias Lütke 536f037e0f Merge pull request #56 from itsmunzir/fix/cross-volume-projection
fix(space): exclude foreign-volume marks from free-space projection
2026-10-04 13:03:22 -04:00
Tobias Lütke b985693ff0 Merge pull request #53 from joshgosse/scan-speed
Improves scan speed on macOS, better memory profile everywhere
2026-10-04 13:03:18 -04:00
kevin9327 13250c0980 Show a size that rounds up to 1024 in the next unit
human_bytes steps up a unit only at 1024, but above 9.95 it prints no decimal, so anything from 1023.5 to 1024 of a unit rounded to "1024 KiB" instead of "1.0 MiB" (1,048,575 bytes, for one). human_count had the same edge at 1000: 999,999 files read "1000.0k". Both now step up where the shown number would round to the next unit.
2026-10-04 20:10:32 +09:00
Tobias Lütke dd0e987190 Merge pull request #52 from kevin9327/flag-non-unicode-export
Flag a marked path whose name is not valid Unicode
2026-10-01 21:45:58 -04:00
Mohammed Munzir dfd1fdc649 fix(space): exclude foreign-volume marks from free-space projection
The free space meter measures the scanned volume, but the projection added
every marked target's bytes. A mark on another volume -- which -X crosses
into, and a disk mounted inside the tree can hold -- gives its space back
there, so the meter lent one disk another's.

Attribute each target to the volume its bytes return to, by the rule the
scan itself bounds a volume with (mount source and type, not a device
number), and project only what comes back to the scanned volume. Marks on
other volumes, snapshot subvolumes, and paths the mount table cannot place
are reported as "not counted here" rather than added; every marked target
is still removable, and the delete list still totals every byte.
2026-09-28 21:25:34 +03:00
Joshua Gosse 48fc31af48 tree: a node is 88 bytes instead of 120
A home directory of 2.6 million directories and 17 million files is
19.7 million nodes, so every field of Node is paid that many times: its
120 bytes were 2.36 GB of the scan's 3.27 GB peak.

- own_bytes and own_files are no longer stored. After aggregate a leaf's
  own figures always equal its totals, and only the selection line reads
  a directory's, so Node::own_bytes() and own_files() sum the direct
  children when asked. A leaf's bytes is now the measured size and the
  only input; de-duplication zeroes it for a second name, as it zeroed
  own_bytes before.
- dirs is a u32, which packs beside the one-byte fields.
- inode is Option<(u64, NonZeroU64)>: no file has inode or file record
  zero, so None fits in the niche and the pair costs 16 bytes, not 24.
  Node::identity() gives the plain pair.

On the same home directory, peak memory for a scan falls from 3,267 MB
to 2,588 MB and node storage from 2,359 MB to 1,731 MB. Trees are
identical to upstream's with de-duplication off (1.25 million nodes
across ~/src, /Applications and /System/Applications, both size modes),
and the totals are identical with it on. a_node_stays_small holds the
size on 64-bit targets.
2026-09-28 09:38:59 -04:00
Joshua Gosse fdc2eb330d scan: list macOS directories with getattrlistbulk, one call per buffer of entries
On macOS the walk listed each directory with std::fs::read_dir and then
called DirEntry::metadata for every file, an lstat of its full path, plus
one more per directory for the dataless flag and the device. On a home
directory of 2.6 million directories and 17 million files that is some
20 million system calls on top of the listing, each of which makes the
kernel set up per-file state.

macos.rs lists a directory with getattrlistbulk(2), which returns the
name, type, device, inode, modification time, flags, link count and sizes
of a whole buffer of entries per call, the way windows.rs already does
with FileIdExtdDirectoryInfo. The sizes are the ones stat reports:
ATTR_FILE_ALLOCSIZE is st_blocks * 512 (every fork, as st_blocks counts),
ATTR_FILE_DATALENGTH is st_size (the data fork). Checked against lstat on
151,000 files across system apps, app bundles, ~/Library and source
trees, and by a test with sparse, hardlinked, symlinked and
resource-forked files. An entry a file system describes only in part is
read with statat relative to the open directory.

Measured on an M5 Pro with 15 walk threads, warm and otherwise idle,
alternating with upstream/main:

  ~/src (88k directories, 696k files)   4.3-4.5 s -> 2.0 s
  whole home directory (2.6M, 17M)      116.6 s -> 90.4-91.6 s

User CPU for the home scan fell from 24.6 s to 9.6 s, and system CPU
from 630 s to 430 s. Trees are identical to the standard listing's with
hardlink de-duplication off (3.3 million nodes, both size modes); with it
on the totals are identical, and which name of a hardlinked file is
charged varies as it already did between runs.

Linux keeps the standard listing, whose DirEntry::metadata is already a
statx relative to the directory; Windows keeps its own.
2026-09-28 09:38:58 -04:00
kevin9327andClaude Opus 5.5 7777720c47 Flag a marked path whose name is not valid Unicode
export::line wrote a path as plain whenever it had no control characters, but display() shows a name that is not valid Unicode with U+FFFD in place of its bytes, so the delete list and the agent prompt named a path that does not exist as one to use. Such a path now goes to the escaped branch, flagged, like a name with a control character.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 22:36:04 +09:00
Harold Hunt 5a170a1b18 chore: add the scan-worker benchmark behind the Power Efficiency table
`examples/scan_workers` runs one scan with a fixed pool of N workers, the
way a preset does, and prints its counts as JSON.
`scripts/bench-scan-workers.py` builds it, runs an untimed warm-up and
rotating rounds under /usr/bin/time, and samples whole-machine CPU. It
prints the median table with deltas against the largest worker count:
scan time, CPU time, and the scan's share of all cores.
2026-09-28 08:19:49 -04:00
Harold Hunt b4e1a22fd9 feat: add saved Power Efficiency scan worker presets 2026-09-27 09:46:00 -04:00
Harold Hunt d448eaa139 Merge origin/main and preserve scan admission integration 2026-09-27 09:31:30 -04:00
Tobi Lutke 231541859a Refuse media exceptions for stacked mount points 2026-09-26 21:59:57 -04:00
Harold Hunt 4e6b15ccfa fix: allow platform-specific CPU sampler fallback lints 2026-09-26 21:58:34 -04:00
Tobi Lutke 955108c13f Preserve independent mount data and allow external media cleanup 2026-09-26 21:58:23 -04:00
Tobi Lutke f3f37c27c4 Merge PR #36: deduplicate repeated filesystem views 2026-09-26 21:48:30 -04:00
Harold Hunt 8df5f69d65 perf: retain direct Rayon dispatch for pool-sized fixed scans 2026-09-26 21:24:32 -04:00
Harold Hunt 30213505c2 perf: bound scan admission and adapt macOS worker budgets 2026-09-26 20:59:01 -04:00
Tobi Lutke dda0a3cbfa Fix Windows integration: responsive volume picker, focus and ordering 2026-09-26 20:34:22 -04:00
Tobi Lutke b2d320a6a5 Merge remote-tracking branch 'origin/pr/41' into windows-integration
# Conflicts:
#	README.md
#	crates/disktree-app/src/views.rs
#	crates/disktree-core/src/windows.rs
2026-09-26 20:24:34 -04:00
Tobi Lutke 57375fcc13 Merge remote-tracking branch 'origin/pr/40' into windows-integration
# Conflicts:
#	crates/disktree-app/src/tests.rs
2026-09-26 20:24:12 -04:00
Abdulwahb Isam 93cb8c64b7 space, app: a volume picker listing every mounted volume and its free space 2026-09-27 00:04:31 +03:00
Abdulwahb Isam 316b91ff7e windows: as_chunks instead of chunks_exact(2), which clippy 1.98 wants 2026-09-27 00:04:27 +03:00
Shishir Pai 4d6a65e00c feat(removal): refuse profile folders and flush after elevated removals 2026-09-26 16:54:16 -04:00
Shishir Pai d2539490fa perf(insights): skip subtrees too small to list 2026-09-26 16:54:16 -04:00
Shishir Pai 03d3e7a159 perf(classify): classify without per-directory allocations 2026-09-26 16:54:16 -04:00
Shishir Pai 0b1725d40e feat(scan): read the NTFS master file table when elevated
Elevated scans of a whole NTFS drive read the master file table in large parallel reads instead of walking directories; any failure falls back to the walk. The walk also allocates once per entry, tallies progress per directory and folds hardlink de-dup into the parallel aggregate pass.
2026-09-26 16:54:16 -04:00
Tyler South c2629ead54 classify: Steam library folders on other drives and Emulation are media 2026-09-26 07:37:32 -04:00
Tyler South 06a8a8b470 scan: a bind mount or a second mount inside the scan is counted once 2026-09-26 07:32:46 -04:00
Tobi LütkeandClaude Opus 5.5 1682463869 review: save the list, or copy it as a prompt for a coding agent
Two ways to hand the marked list on instead of acting on it. `s` saves
the paths the plan would act on, one per line. `a` copies instructions
for an agent: free the space by removing exactly these, checking each
first (unpushed git work, a tool's own clean command), trash over delete,
and report back. A name with a control character is left out of the list
and escaped in the prompt, so a newline cannot pass for another path or
close the list and carry on as instructions.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 16:24:03 +00:00
Tobi LütkeandClaude Opus 5.5 670407f37e removal: Homebrew on Linux, Guix and the extra lib dirs are system trees; so are Windows' page and hibernation files
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 16:20:24 +00:00
Tobi LütkeandClaude Opus 5.5 e1851c624b scan: the hidden attribute hides an entry on Windows, as Explorer does
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 16:19:45 +00:00
Tobi LütkeandClaude Opus 5.5 a64a58060d removal: read Windows' volume list, so a volume mounted inside a target is refused
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 16:17:59 +00:00
Tobi LütkeandClaude Opus 5.5 2ed6720638 classify: Windows temp, crash dumps, caches, Recycle Bin and sync folders
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 16:17:59 +00:00
Tobi LütkeandClaude Opus 5.5 46711fc816 removal: a target under the Data volume's root is inside it
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 15:39:33 +00:00
Tobi LütkeandClaude Opus 5.5 b9ba523a92 removal: follow links above the scanned root, only refuse them below
Walking from / with O_NOFOLLOW refused every path under /var and /tmp
on macOS, which are links. Open the root as named and refuse links only
between it and the target, as the plan does. Also two tests that assumed
Unix now run or skip on Windows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 15:21:12 +00:00
Tobi LütkeandClaude Opus 5.5 d37870cdea removal: refuse names Win32 misreads, links on the way down, and home by its real path
- Windows strips trailing dots and spaces and maps NUL/COM1 to devices,
  so a scanned `C:\Users.` would have removed `C:\Users`. Refused.
- The trash (everywhere) and removal on Windows follow a link on the way
  to a target out of the scanned root. The real parent is compared with
  the real root, in the plan and again on the worker.
- The home directory is also matched by its canonical path, so a link
  such as /home -> /data/home no longer hides it from 'contains home'.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 14:27:05 +00:00
Tobi LütkeandClaude Opus 5.5 1220150762 removal: close the path race, and judge mounts again before removing
Permanent deletion opened its target by full path, following any
symlink on the way down. A directory swapped for a link after the scan
(a shared /tmp, say) redirected the removal: `/tmp/d/x` marked, `d`
made a link to `~`, and `~/x` went. The way down is now opened one
component at a time with O_NOFOLLOW (O_PATH on Linux), and the target
removed with unlinkat relative to its parent. The scanned root is
canonical, so a marked path never legitimately has a link on it.

The plan is judged against a mount table read on a background thread,
empty until the first read lands and up to two seconds old after. The
removal worker now reads it fresh and checks each target for a mount
point on it or inside it before touching anything. Permanent deletion
stopped at a mount boundary already; the trash did not.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 14:14:22 +00:00
Tobi LütkeandClaude Opus 5.5 f39f96e62f Merge pr/14 (Windows) onto the macOS port
One set of removal guards for all three platforms: guard_key folds
macOS firmlinks and case, and now Windows case and verbatim prefixes,
so within/same from #14 become key comparisons. System trees are one
keyed list per platform.

Fixed while merging:
- plan() found home through $HOME, which Windows does not set, so every
  home guard was off there; std::env::home_dir() instead.
- Scan: #14's Listed/Facts shape with #13's never-scanned paths,
  dataless iCloud folders and track-only-shared-inodes; OneDrive
  cloud-only folders are skipped the same way on Windows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 14:14:22 +00:00
Oleg Shevchuk cac3d76c3f core: refuse a directory that holds the home directory
Removing a directory takes what is inside it. In a whole-disk scan on
Windows, C:\Users is an ordinary directory that passes every other
guard, and so is /home on a Linux install without a separate volume:
marking either would remove the home directory the guards are there to
protect.
2026-09-25 15:09:09 +05:00
Oleg Shevchuk f3741c1a51 core: list, measure and remove on Windows
disktree-core builds and measures on Windows. `windows.rs` holds what the
standard library does not give: a directory listing through
GetFileInformationByHandleEx with FileIdExtdDirectoryInfo, which carries
each entry's allocation and file id for a whole buffer of entries.
Opening every file for those two numbers made a walk of a home directory
of 1.3 million files seven times slower (65 s against 9 s); the listing
costs what FindNextFileW costs. Where a file system does not implement
it (a Samba share answers ERROR_INVALID_LEVEL), the walk falls back to
std's listing, with lengths.

- Disk usage is the NTFS allocation: whole clusters, less for a
  compressed or sparse file, nothing for data kept in the file record.
- Hardlinks count once on NTFS, keyed by volume serial and file id. FAT
  ids are documented as not unique and ReFS ids need all 128 bits, so
  neither is used; there a hardlink counts once per name.
- Junctions and mounted folders are links, as std already treats them,
  so the walk stays on one volume unless links are followed. The whole
  disk is the drive the profile is on.
- Removal refuses Windows, Program Files, ProgramData and what Windows
  keeps at the top of its drive, comparing names without case. A mounted
  folder is a mount point. A link to a directory is removed with
  RemoveDirectoryW, which leaves its target alone.
- Move to trash is the Recycle Bin, through the trash crate, which asks
  the shell to warn before destroying anything it cannot recycle.

All unsafe code is in windows.rs, each block with the reason it is sound.
On Unix the walk reads the same metadata through the same calls.
2026-09-25 15:08:55 +05:00
Sebastian Sieber cbdfe1c332 macOS support: native Trash, APFS-aware scans, a signed app bundle
disktree built and drew on macOS already, through GPUI's Metal backend,
but the Linux plumbing underneath did not carry over. This makes it work
well there, without unsafe code, and tightens removal safety for every
platform on the way.

Trash and removal
- On macOS always the system Trash, through NSFileManager (the trash
  crate): the same move as Finder's, into the item's own disk's Trash.
  gio/trash-put/XDG would put files in ~/.local/share/Trash, which Finder
  never shows.
- Refuse a directory holding the home directory (/Users is on the same
  volume as / on macOS) or a system tree (/opt holds /opt/homebrew); add
  /System, /Library, /private, /opt/homebrew, /cores, /Network.
- Refuse a directory with a mount inside it; on macOS the mount list comes
  from /sbin/mount, read on a background thread.
- Permanent deletion walks the tree itself and stops at a mount boundary,
  like rm -rf --one-file-system (the walker is from #10).
- Guards see through /System/Volumes/Data spellings and, on macOS, case.

Scanning
- Skip /System/Volumes/Data when scanning /: it is /Users, /Applications
  and the rest again under firmlinks, so / was counted twice.
- Whole disk (g, --disk) works: the disk root and device come from statfs.
- Never list cloud-only (dataless) iCloud/File Provider folders, which
  would download them.
- Keep a file's identity only when it has more than one name.

App
- Explain unreadable items when Full Disk Access is missing, with a button
  to the privacy settings.
- A menu bar: Open Folder… (⌘O), Show in Finder (o, ⌘⇧R), Rescan (⌘R),
  Hide, Quit; closing the window quits; other ⌘ chords are not read as
  plain letters; help shows ⌘.
- Follow the system light/dark appearance when no Omarchy theme exists.
- Worth a look knows Xcode DerivedData, DeviceSupport and ~/Library/Logs.
- git: skipped without the developer tools (its stub opens a dialog), and
  never runs a checkout's programs: fsmonitor, hooks and pager off, and no
  status for a checkout that defines its own filter drivers.

Packaging
- cargo xtask bundle builds disktree.app and a zip: Info.plist (bundle id
  io.github.tobi.disktree, macOS 11+), an icon drawn from an SVG on the
  macOS grid, ad-hoc or Developer ID signing, and --notarize.
- make install on macOS puts the app in ~/Applications and links
  ~/.local/bin/disktree to it.
- CI lints, tests and bundles on macOS; the release adds an arm64 macOS
  zip, signed and notarized when the repository has the Apple secrets.
2026-09-25 17:29:55 +08:00
Tobi Lutke 23b9e5d21b core: memoized widening and name filtering
- scan: spawn_with takes a Known subtree and reuses it where the walk
  reaches it, so widening from ~ to / reads only what is outside ~.
- filter: which nodes match a name, ignoring ASCII case without
  allocating. Matches are kept whole; their ancestors are kept sized by
  what matched beneath them.
- treemap: layout_filtered lays out only what a filter keeps.
2026-09-24 16:51:31 -05:00
Tobi Lutke 5b7361b015 core: kinds, findings, and scanning a whole disk
- classify: a category per node (code, agent scratch, toolchains, synced,
  git, media, documents, cache) from names and shapes — a bare repository
  is git whatever it is called — and a reclaim reason for caches, sync
  history, package stores and build output beside its manifest.
- insights: "worth a look", the largest findings that never nest:
  reclaimable space, agent worktrees, experiments untouched for a month.
- nodes carry their newest write time, rolled up by aggregate.
- space: a mount-table model of a volume. One volume is one mount source,
  so btrfs subvolumes (/home, /var/log) stay in and /proc, tmpfs, /boot,
  network shares and automount points stay out, checked by path so a NAS
  is never mounted to be measured. Staying on the volume is now the
  default; volume_root finds the disk a home directory lives on.
- removal: system trees (/usr, /etc, /var/lib, /nix/store, …) are refused.
- treemap: wider gaps between top-level directories, full name bands only
  at the first level and a slim label row below it.
2026-09-24 16:42:08 -05:00
Tobi Lutke 60209e9cae disktree-core: scan, layout, free space and removal
- scan: dust's approach — one rayon scope, a +1 completion counter per
  directory, bottom-up aggregation — with live progress and cancellation.
  Disk usage by default, hardlinks counted once, symlinks not followed.
- tree: nodes with derived totals; aggregate() is the single source.
- treemap: squarified layout in viewport pixels, a name band per
  subdivided directory, and crumbs that always address the scanned tree.
- space: statvfs, and the projection after removing marked bytes.
- removal: guarded plans (root, home, scanned root, mount points and
  paths outside the root are refused), rm -rf semantics without a shell,
  and trash via trash-put, gio or a built-in XDG implementation.
2026-09-24 15:56:19 -05:00