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
Keep the folders an open app's updater fills, as its own cache is kept
Țugui Dragoș6bd76f1237bd
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swiftindex c00238ce..317fa5ac 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift@@ -491,8 +491,8 @@ public enum Installers {for url in files(in: caches) where url.isRealFolder {let name = url.lastPathComponentguard !developers.contains("library/caches/" + name.lowercased()) else { continue }- if name.hasSuffix(".ShipIt") {- let identifier = String(name.dropLast(".ShipIt".count))+ if name.hasSuffix(Squirrel.folderSuffix) {+ let identifier = String(name.dropLast(Squirrel.folderSuffix.count))found.append((url, identifier, installed(identifier)))}let sparkle = url.appending(path: "org.sparkle-project.Sparkle", directoryHint: .isDirectory)diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swiftindex 03165bd9..e96d9dd1 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift@@ -224,8 +224,8 @@ public enum SpaceRemoval {/// Maps each name an open app answers to, normalized, to the app's display name. The names are the bundle/// identifier, its last part, and the bundle's file name, since many cache and log folders carry the app's- /// name rather than its identifier (`Firefox`, `Zed`), and the application groups its signature claims, whose- /// group containers it shares with other apps of its maker.+ /// name rather than its identifier (`Firefox`, `Zed`), the application groups its signature claims, whose+ /// group containers it shares with other apps of its maker, and the folders its updater fills while it runs.static func namesOfRunningApps(_ running: [RunningCopies.Process]) -> [String: String] {var names: [String: String] = [:]for process in running {@@ -239,6 +239,7 @@ public enum SpaceRemoval {process.bundleIdentifier?.split(separator: ".").last.map(String.init),bundle,].compactMap(\.self) + (process.bundleURL.map(AppInspector.applicationGroups) ?? [])+ + updaterFolders(of: process)for spelling in spellings where Naming.isSignificant(spelling) {names[Naming.normalized(spelling)] = displayed}@@ -246,4 +247,12 @@ public enum SpaceRemoval {return names}+ /// Squirrel's folder, named for the app's identifier, and electron-updater's, named in its `app-update.yml`.+ private static func updaterFolders(of process: RunningCopies.Process) -> [String] {+ let squirrel = process.bundleIdentifier.map { $0 + Squirrel.folderSuffix }+ let electron = process.bundleURL+ .flatMap { ElectronUpdater.configuration(in: $0.appending(path: "Contents", directoryHint: .isDirectory)) }+ .flatMap(ElectronUpdater.downloadsFolder(fromConfiguration:))+ return [squirrel, electron].compactMap(\.self)+ }}diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/Squirrel.swift b/Packages/PeelCore/Sources/PeelCore/Updates/Squirrel.swiftnew file mode 100644index 00000000..663ddf18--- /dev/null+++ b/Packages/PeelCore/Sources/PeelCore/Updates/Squirrel.swift@@ -0,0 +1,6 @@+/// Squirrel.Mac, the updater many Electron apps ship, keeps an app's downloaded and staged update in the user's Caches+/// folder, in a folder named for the app's identifier with this after it (`SQRLShipItLauncher.m`,+/// `SQRLDirectoryManager.m`).+enum Squirrel {+ static let folderSuffix = ".ShipIt"+}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swiftindex 47d63be2..022ee483 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift@@ -507,6 +507,26 @@ struct SpaceRemovalTests {#expect(plan.appsToQuit == ["Firefox", "Zed"])}+ @Test func leavesAloneTheFoldersAnOpenAppsUpdaterFills() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("home/Library/Caches/org.example.chat.ShipIt/ShipItState.plist")+ try directory.file("home/Library/Caches/example-chat-updater/pending/update-info.json")+ try directory.file("home/Library/Caches/com.gone.app/old.db")+ let configuration = "provider: generic\nurl: https://example.org/updates\nupdaterCacheDirName: example-chat-updater\n"+ try directory.file("Applications/Chat.app/Contents/Resources/app-update.yml", contents: Data(configuration.utf8))+ let chat = directory.url.appending(path: "Applications/Chat.app", directoryHint: .isDirectory)+ let running = [RunningCopies.Process(identifier: 1, bundleIdentifier: "org.example.chat", bundleURL: chat)]++ let plan = await SpaceRemoval.plan(+ for: item(directory),+ environment: environment(directory),+ running: SpaceRemoval.namesOfRunningApps(running)+ )++ #expect(plan.removable.map(\.lastPathComponent) == ["com.gone.app"])+ #expect(plan.inUse.map(\.url.lastPathComponent).sorted() == ["example-chat-updater", "org.example.chat.ShipIt"])+ }+/// One open app can write to several folders, by its name and by its identifier. The note names it once.@Test func namesAnOpenAppOnceWhateverItsFoldersAreCalled() async throws {let directory = try TemporaryDirectory()