Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Let App Folders take a folder deeper in Applications than Peel looks
Țugui Dragoșa42d0b39a1dd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex de91fde3..52322eec 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -127,6 +127,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.- The Helper tab names every order the helper takes, and Remove Peel's notes name everything Peel's folder holds andwhat Homebrew's zap also does.- App Folders gives each reason it refuses a folder a sentence of its own.+- App Folders takes a folder deeper inside an Applications folder than Peel looks, such as the one Unity Hub keeps+ its editors in.#### Applicationsdiff --git a/GUIDE.md b/GUIDE.mdindex 3253ca72..67138c60 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -55,7 +55,8 @@ and how to get it, [SAFETY.md](SAFETY.md) what it protects, [PRIVACY.md](PRIVACYwhat it left behind, while Peel is open or in the menu bar, and once it has Full Disk Access. An old copy thrownaway while another copy of the app is still installed brings no such offer, since nothing was left behind. Appsyou keep outside the Applications folders, such as on another disk, join the list once you add their folder in- Settings > General > App Folders.+ Settings > General > App Folders, and so do apps kept deeper in an Applications folder than the three levels Peel+ looks through, such as the editors Unity Hub installs in `/Applications/Unity/Hub/Editor`.- **Reset instead of remove.** Reset, on an app's page, clears its settings without uninstalling it, and neverselects your own work. Peel saves a copy of the settings first: put them back from the Reset sheet right away, orlater from Settings > General > Saved Settings, which keeps each copy until you move it to the Trash, since a copydiff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swiftindex 56781f55..f4338e77 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift@@ -229,10 +229,19 @@ public enum AppCatalog {}}- /// The apps in `directory`, three levels deep, and the folders in it that are there and could not be read. A+ /// How many levels below each folder apps are looked for.+ static let depth = 3++ /// Whether `appBundles` looks inside `folder` when it meets it: it passes over hidden folders and packages.+ static func looksInside(_ folder: URL) -> Bool {+ let values = try? folder.resourceValues(forKeys: [.isHiddenKey, .isPackageKey])+ return values?.isHidden != true && values?.isPackage != true+ }++ /// The apps in `directory`, `depth` levels deep, and the folders in it that are there and could not be read. A/// folder that is not there, such as an Applications folder nobody made, holds no app.static func appBundles(- in directory: URL, maximumDepth: Int = 3, unless isStopped: () -> Bool = { false }+ in directory: URL, unless isStopped: () -> Bool = { false }) -> (bundles: [URL], unreadable: [URL]) {var unreadable: [URL] = []guard let enumerator = FileManager.default.enumerator(@@ -250,7 +259,7 @@ public enum AppCatalog {guard !isStopped() else { break }if url.pathExtension == "app" {bundles.append(url.standardizedFileURL)- } else if enumerator.level >= maximumDepth {+ } else if enumerator.level >= depth {enumerator.skipDescendants()}}diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swiftindex 9992826e..237b59f0 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift@@ -8,7 +8,7 @@ public struct AppFolders: Sendable {/// A whole disk, the home folder, a Library or its Application Support, or one of macOS's own folders, which/// would make every reading of the apps slow.case tooBroad- /// An Applications folder, or one inside it, which Peel already looks in.+ /// An Applications folder, or a folder inside one that Peel already reads (`AppCatalog.depth`).case alreadyLookedIn/// The Trash, or a folder in it, which holds what is on its way out.case inATrash@@ -88,8 +88,13 @@ public struct AppFolders: Sendable {if TrashService.isAtOrInsideATrash(folder, home: home) { return .inATrash }// Listing a folder a cloud keeps can download what it holds.if isInTheCloud(folder) { return .inTheCloud }- let lookedIn = AppCatalog.standardDirectories(home: home).contains {- PathComponents.isPath(path, atOrInside: folded($0))+ // A folder deeper than the reading of an Applications folder goes, or one it passes over, is taken.+ let lookedIn = AppCatalog.standardDirectories(home: home).contains { directory in+ let base = PathComponents.of(folded(directory))+ let levels = names.count - base.count+ guard levels >= 0, levels < AppCatalog.depth, names.starts(with: base) else { return false }+ return sequence(first: folder) { $0.deletingLastPathComponent() }.prefix(levels)+ .allSatisfy(AppCatalog.looksInside)}return lookedIn ? .alreadyLookedIn : nil}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swiftindex 0509f6be..6f42c0c2 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift@@ -18,6 +18,30 @@ struct AppFoldersTests {}}+ @Test func refusesAsLookedInExactlyWhatTheWalkOfAnApplicationsFolderReads() throws {+ let directory = try TemporaryDirectory()+ let paths = [+ "Applications/Suite", "Applications/Suite/Pro", "Applications/Suite/Pro/Editor",+ "Applications/Suite/Pro/Editor/2026", "Applications/.Hidden", "Applications/.Hidden/Inner",+ "Applications/Tool.app/Contents", "Applications/Tool.app/Contents/Helpers",+ ]+ let folders = try paths.map { try directory.directory($0) }+ for path in paths {+ try directory.directory(path + "/Probe.app")+ }++ let found = Set(AppCatalog.appBundles(in: directory.url.appending(path: "Applications")).bundles.map {+ PathPattern.comparablePath(of: $0)+ })++ for folder in folders {+ let isFound = found.contains(PathPattern.comparablePath(of: folder.appending(path: "Probe.app")))+ let isRefused = AppFolders.refusal(of: folder, home: directory.url) == .alreadyLookedIn+ #expect(isRefused == isFound, "\(folder.lastPathComponent)")+ }+ #expect(AppFolders.refusal(of: folders[2], home: directory.url) == nil, "Unity Hub's Editor folder")+ }+@Test func refusesAWholeDiskMacOSsOwnFoldersAndTheCloud() {let home = URL(filePath: "/Users/someone", directoryHint: .isDirectory)func refusal(_ path: String, inTheCloud: Bool = false) -> AppFolders.Refusal? {