Skip to content

macOS support: native Trash, APFS-aware scans, a signed app bundle - #13

Merged
tobi merged 1 commit into
tobi:mainfrom
sebastiansieber:macos-support
Sep 25, 2026
Merged

tobi merged 1 commit into
tobi:mainfrom
sebastiansieber:macos-support

Conversation

@sebastiansieber

Copy link
Copy Markdown
Contributor

disktree already builds and draws on macOS through GPUI's Metal backend, but the Linux plumbing underneath didn't carry over. On a Mac today:

  • Move to trash puts files in ~/.local/share/Trash, which Finder never shows, while the app says they can be recovered.
  • Scanning / counts user data twice. /Users and /System/Volumes/Data/Users are the same inode on the same device.
  • Whole-disk mode (g, --disk) does nothing, because it reads /proc/self/mounts.
  • The removal guards don't know macOS. /Users, /opt and /Volumes could all be marked in a whole-disk scan, and a permanent delete of /Users would empty the home directory before failing.

This PR fixes those and makes disktree behave like a Mac app. It adds no unsafe code. Several ideas come from the other open macOS PRs, credited below.

Trash and removal

  • Trash on macOS always uses the system Trash, through NSFileManager via the trash crate (a macOS-only dependency). It's the same move Finder makes, into the Trash of the item's own disk. There's no Automation prompt and no /usr/bin/trash, which only exists on macOS 15 and later.
  • More folders are refused:
    • a folder that holds the home directory or a system tree;
    • a folder with another filesystem mounted inside it. On macOS the mount list comes from /sbin/mount, read on a background thread because the review screen plans on every frame;
    • /System, /Library, /private, /opt/homebrew, /cores and /Network, added to the system trees.
  • Permanent deletion walks the tree itself and stops at a mount boundary, like rm -rf --one-file-system. The walker is from Never delete into a filesystem mounted inside a marked directory #10; this PR compares mount IDs where Linux has them, so a btrfs subvolume that isn't mounted goes with its directory.
  • The guards compare /System/Volumes/Data/... paths as /... and ignore case on macOS. They also match the home directory by device and inode.

Scanning

  • A scan of / skips /System/Volumes/Data and /Network. Staying on one filesystem still works by comparing devices.
  • The disk root and device name come from statfs. The Data volume maps to /, so widening from ~ reuses the tree that's already measured.
  • Cloud-only (dataless) iCloud and File Provider folders are never listed, since listing one makes macOS download it.
  • A file's identity is kept only when it has more than one name (from add native macOS support and faster filesystem scanning #3).

App

  • Full Disk Access: when items can't be read and the permission is missing, the panel says so and has a button to the privacy settings.
  • Menu bar: Open Folder… (⌘O), Show in Finder (o, ⌘⇧R, via GPUI's reveal_path), Rescan (⌘R), Hide and Quit.
    • Closing the window quits.
    • Other ⌘ chords aren't read as plain letters; ⌘D used to toggle apparent size.
    • The help shows ⌘.
  • Appearance: follows the system's light or dark mode when there's no Omarchy theme.
  • Worth a look knows Xcode DerivedData, DeviceSupport and ~/Library/Logs.
  • git:

Packaging

  • cargo xtask bundle builds target/bundle/disktree.app and a zip, using only tools that ship with macOS or Xcode:
    • an Info.plist with bundle id io.github.tobi.disktree, macOS 11+, and the folder-access prompt texts;
    • an icon drawn from packaging/macos/AppIcon.svg on the macOS icon grid;
    • an ad-hoc signature, or a Developer ID one with --sign; --notarize notarizes, staples and checks the result.
  • make install on macOS puts the app in ~/Applications and links ~/.local/bin/disktree to it.
  • CI lints, tests and bundles on macos-15. The release adds a disktree-*-aarch64-macos.zip, signed and notarized only when the repository has the Apple secrets listed in release.yml. Without them the zip is signed ad hoc.

Verified

  • Lint and tests: cargo xtask lint and cargo xtask test pass on macOS 26 (Apple silicon), with 148 tests. disktree-core also passes clippy for x86_64-unknown-linux-gnu.
  • Whole-disk scan: 275 GiB against about 295 GiB used, with no double counting. The gap is space the scan can't read without Full Disk Access, plus snapshots.
  • Trash: a real move put the file in the Finder Trash, and a trashed symlink left its target alone.
  • git: without the filter check, a planted clean filter runs on git status. A test now covers this.
  • App bundle: it launches and quits normally, including with the hardened runtime on.

Not verified

  • The Linux build of the app crate: it can't be cross-compiled from a Mac, so CI will show it.
  • Notarization, because I don't have a Developer ID certificate here.
  • The menu bar and the Finder and folder-picker windows. They have to be tried by hand.

Related

It overlaps with #1, #3, #7 and #8 (macOS) and with #6 and #10. This PR takes #10's deletion walker and git settings, and ideas from #3 and #8.

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 tobi#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.
@tobi
tobi merged commit df03ca8 into tobi:main Sep 25, 2026
pull Bot pushed a commit to jasonkneen/disktree that referenced this pull request Sep 25, 2026
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 tobi#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: tobi#14's Listed/Facts shape with tobi#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>
@jasonkneen

Copy link
Copy Markdown
Screenshot 2026-09-25 at 18 10 55

Shame that Github doesn't count mentions like this as being part of the contribution criteria.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants