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
Say in History that an app shared its storage with another copy
Țugui Dragoș8b26d92bb624
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 30670dd0..6aa4ab25 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -62269,6 +62269,112 @@}}},+ "It shared most of its storage with another copy, so moving it freed only its own part." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplikace sdílela většinu svého místa na disku s jinou kopií, takže jejím přesunutím se uvolnila jen ta část, kterou nesdílela."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Diese App teilte sich den Großteil ihres Speicherplatzes mit einer anderen Kopie, daher gab ihr Verschieben nur ihren eigenen Teil frei."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Compartía la mayor parte de su almacenamiento con otra copia, así que trasladarla solo liberó la parte que no compartía."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Cette app partageait l’essentiel de son stockage avec une autre copie, si bien que la déplacer n’a libéré que sa propre part."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Condivideva la maggior parte del suo spazio su disco con un’altra copia, quindi spostarla ha liberato solo la parte non condivisa."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "別のコピーとストレージの大部分を共有していたため、移動して解放されたのは、共有していなかった部分だけでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "다른 복사본과 저장 공간 대부분을 공유했으므로, 이동해도 공유하지 않은 부분의 공간만 확보되었습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Deze app deelde het grootste deel van zijn opslag met een andere kopie, dus bij het verplaatsen kwam alleen zijn eigen deel vrij."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ta aplikacja współdzieliła z inną kopią większość zajmowanego miejsca na dysku, więc przeniesienie jej zwolniło tylko jej własną część."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Este app compartilhava a maior parte do armazenamento com outra cópia, então movê-lo liberou apenas a parte exclusiva dele."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplicația partaja cea mai mare parte a spațiului de stocare cu o altă copie, așa că mutarea ei a eliberat doar partea proprie."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Большая часть пространства на диске, занятого приложением, была общей с другой копией, поэтому при перемещении освободилась только его собственная часть."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Appen delade det mesta av sitt lagringsutrymme med en annan kopia, så när den flyttades frigjordes bara dess egen del."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Saklama alanının çoğunu başka bir kopyasıyla paylaşıyordu, bu yüzden onu taşımak yalnızca kendine ait kısmı kadar yer boşalttı."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Програма спільно використовувала більшу частину свого сховища з іншою копією, тож її переміщення звільнило лише її власну частину."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它与另一个副本共享了大部分储存空间,因此移动它只释放了它独有的那部分空间。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此App與另一個副本共用大部分儲存空間,因此移動它只釋放了其獨有的部分。"+ }+ }+ }+ },"It still leads to something on this Mac." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Removals.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Removals.swiftindex 96054caa..3437217d 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Removals.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Removals.swift@@ -9,6 +9,7 @@ enum Removals {from source: String,key sourceKey: String? = nil,sizes: [URL: Int64],+ sharingStorage: Set<URL> = [],tool: String,in log: RemovalLog = RemovalLog(),refusals: RefusalLog = RefusalLog()@@ -17,7 +18,8 @@ enum Removals {var isRecorded = trueif !result.trashed.isEmpty {let part = RemovalPart(source: source, sourceKey: sourceKey, tool: tool)- isRecorded = await log.add(part.records(of: result, sizes: sizes, batch: UUID())).records != nil+ let records = part.records(of: result, sizes: sizes, sharingStorage: sharingStorage, batch: UUID())+ isRecorded = await log.add(records).records != nil}if let problem = await refusals.add(result.failures, source: source, sourceKey: sourceKey, tool: tool) {Output.note(problem.summary)diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/UninstallPlan.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/UninstallPlan.swiftindex 78742314..6f1aff66 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/UninstallPlan.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/UninstallPlan.swift@@ -22,6 +22,7 @@ struct UninstallPlan {let needsReview: Intvar uninstallsItself = falsevar makersFolderNames: Set<String> = []+ var appSharesStorage = falsevar moving: [Item] { items.filter { $0.refusal == nil } }var staying: [Item] { items.filter { $0.refusal != nil } }@@ -63,7 +64,8 @@ struct UninstallPlan {needsAdministrator: rest.count(where: { $0.match.isRecommended && $0.requiresPrivileges }),needsReview: rest.count(where: { !$0.match.isRecommended && $0.match.heldBack != .leftToItsUninstaller }),uninstallsItself: uninstallation.uninstallsItself != nil,- makersFolderNames: uninstallation.makersFolderNames+ makersFolderNames: uninstallation.makersFolderNames,+ appSharesStorage: uninstallation.appSharesStorage)}@@ -82,6 +84,7 @@ struct UninstallPlan {result,from: source,sizes: [URL: Int64](measured: items.map { ($0.url, $0.size) }),+ sharingStorage: appSharesStorage ? [app] : [],tool: "applications",in: log,refusals: refusalsdiff --git a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swiftindex 1c994a08..efb93eab 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift@@ -28,6 +28,8 @@ public struct BulkUninstallation: Sendable {public var removedElsewhere: RemovedElsewhere?/// An app's bundle already in the Trash. Shown, never selected, never counted.public var isInTheTrash = false+ /// An app's bundle that shares most of its storage with another copy (`Uninstallation.appSharesStorage`).+ public var sharesStorage = false/// The package an app's bundle sits inside (`InstalledApp.enclosingPackage`). Shown, never selected, never/// moved.public var enclosingPackage: URL?@@ -276,6 +278,7 @@ public struct BulkUninstallation: Sendable {isBeyondTheHelper: uninstallation.isAppBeyondTheHelper,removedElsewhere: uninstallation.removedElsewhere,isInTheTrash: uninstallation.isAppInTheTrash,+ sharesStorage: uninstallation.appSharesStorage,enclosingPackage: uninstallation.app.enclosingPackage))}diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGrouping.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGrouping.swiftindex 6e9ee984..87799082 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGrouping.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGrouping.swift@@ -94,7 +94,12 @@ public struct RemovalPart: Sendable, Hashable {extension RemovalPart {/// History's records of what moved from this part, all in `batch`, each with its size in `sizes`, and none/// where it was not measured.- public func records(of result: TrashResult, sizes: [URL: Int64], batch: UUID) -> [RemovalRecord] {+ public func records(+ of result: TrashResult,+ sizes: [URL: Int64],+ sharingStorage: Set<URL> = [],+ batch: UUID+ ) -> [RemovalRecord] {result.trashed.map {RemovalRecord(batch: batch,@@ -102,7 +107,8 @@ extension RemovalPart {size: sizes[$0.originalURL] ?? (result.emptied.contains($0.originalURL) ? 0 : nil),source: source,sourceKey: sourceKey,- tool: tool+ tool: tool,+ sharedStorage: sharingStorage.contains($0.originalURL) ? true : nil)}}diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swiftindex fd8bcf74..9ecc285f 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift@@ -20,6 +20,8 @@ public struct RemovalRecord: Sendable, Codable, Hashable, Identifiable {/// History can show it in the user's language. `source` then holds the English name, which `peel` prints.public let sourceKey: String?public let stoppedJob: String?+ /// True when the item shared most of its storage with another copy, so moving it freed only its own part.+ public let sharedStorage: Bool?public init(id: UUID = UUID(),@@ -28,7 +30,8 @@ public struct RemovalRecord: Sendable, Codable, Hashable, Identifiable {size: Int64?,source: String,sourceKey: String? = nil,- tool: String+ tool: String,+ sharedStorage: Bool? = nil) {self.id = idself.batch = batch@@ -41,6 +44,7 @@ public struct RemovalRecord: Sendable, Codable, Hashable, Identifiable {self.sourceKey = sourceKeyself.tool = toolstoppedJob = item.stoppedJob+ self.sharedStorage = sharedStorage}/// Reads a negative size as zero, since any process of the user can rewrite the History file.@@ -57,6 +61,7 @@ public struct RemovalRecord: Sendable, Codable, Hashable, Identifiable {tool = try container.decode(String.self, forKey: .tool)sourceKey = try container.decodeIfPresent(String.self, forKey: .sourceKey)stoppedJob = try container.decodeIfPresent(String.self, forKey: .stoppedJob)+ sharedStorage = try container.decodeIfPresent(Bool.self, forKey: .sharedStorage)}public var trashedItem: TrashedItem {diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalRequest.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalRequest.swiftindex c97af918..6d43903f 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalRequest.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalRequest.swift@@ -6,10 +6,12 @@ public struct RemovalRequest: Sendable, Equatable {public let urls: Set<URL>/// The size of each item the scan measured. An item missing here was not measured.public let sizes: [URL: Int64]+ public let sharingStorage: Set<URL>- public init(urls: Set<URL>, sizes: [URL: Int64]) {+ public init(urls: Set<URL>, sizes: [URL: Int64], sharingStorage: Set<URL> = []) {self.urls = urlsself.sizes = sizes+ self.sharingStorage = sharingStorage.intersection(urls)}public var total: SizeTotal {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swiftindex f390dd55..3e8292f9 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift@@ -32,6 +32,17 @@ struct BulkUninstallationTests {)}+ @Test func anAppsBundleSaysItSharesItsStorage() {+ let clone = app("org.example.clone", "Clone")+ let own = app("org.example.own", "Own")+ var shared = uninstallation(clone, [])+ shared.appSharesStorage = true++ let bulk = BulkUninstallation(uninstallations: [shared, uninstallation(own, [])])++ #expect(bulk.items.filter { $0.sharesStorage }.map { $0.url } == [clone.url])+ }+@Test func aChosenAppsBundleStaysAnAppWhenAnotherChosenAppListsIt() {let synth = app("org.example.synth", "Synth")let effects = app("org.example.synth-fx", "Synth Effects")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CleanupTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CleanupTests.swiftindex fb997632..e454b999 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CleanupTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CleanupTests.swift@@ -254,6 +254,24 @@ struct CleanupTests {#expect(records.count == 3)}+ @Test func anUninstallRecordsThatTheAppSharedItsStorage() async throws {+ let directory = try TemporaryDirectory()+ let app = try directory.directory("home/Applications/Twin.app")+ let log = RemovalLog(url: directory.url.appending(path: "Peel/removals.json"))+ var uninstallation = Uninstallation(+ app: InstalledApp(url: app, bundleIdentifier: "org.example.twin", name: "Twin"),+ appSize: 0,+ appRequiresPrivileges: false,+ scan: LeftoverScan(leftovers: [], unreadableLocations: [])+ )+ uninstallation.appSharesStorage = true+ let plan = UninstallPlan.make(uninstallation, keepLeftovers: true, refusal: { _ in nil })++ #expect(await plan.record(await plan.move(using: try service(in: directory)), from: "Twin", in: log))++ #expect(await RemovalLog(url: log.url).load().records?.map(\.sharedStorage) == [true])+ }+/// `peel uninstall` writes down what the guard refused before the move beside what moved, as every other/// command does, and an app the guard keeps where it is is written down too, though nothing moved.@Test func anUninstallWritesDownWhatTheGuardRefusedBeforeTheMove() async throws {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RemovalGroupingTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RemovalGroupingTests.swiftindex 7ffea518..b7e9a973 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/RemovalGroupingTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/RemovalGroupingTests.swift@@ -45,6 +45,31 @@ struct RemovalGroupingTests {#expect(before.source == "Duplicates")}+ @Test func aRecordSaysItsItemSharedItsStorage() throws {+ let item = { (name: String) in+ TrashedItem(+ originalURL: URL(filePath: "/Applications/\(name).app"),+ trashedURL: URL(filePath: "/Users/x/.Trash/\(name).app"),+ date: Date(timeIntervalSince1970: 1_800_000_000)+ )+ }+ let (clone, own) = (item("Clone"), item("Own"))+ let part = RemovalPart(source: "Example", sourceKey: nil, tool: "applications")++ let records = part.records(+ of: TrashResult(trashed: [clone, own]),+ sizes: [clone.originalURL: 0, own.originalURL: 10],+ sharingStorage: [clone.originalURL],+ batch: UUID()+ )++ #expect(records.map { $0.sharedStorage } == [true, nil])+ let copy = try JSONDecoder().decode(RemovalRecord.self, from: JSONEncoder().encode(records[0]))+ #expect(copy.sharedStorage == true)+ let plain = try JSONSerialization.jsonObject(with: JSONEncoder().encode(records[1])) as? [String: Any]+ #expect(plain?["sharedStorage"] == nil)+ }+@Test func groupsARemovalAndPutsTheNewestFirst() {let now = Date(timeIntervalSince1970: 1_800_000_000)let older = UUID()diff --git a/Peel/Model/BulkRemovalPlan.swift b/Peel/Model/BulkRemovalPlan.swiftindex 1cb83442..b6d7c99f 100644--- a/Peel/Model/BulkRemovalPlan.swift+++ b/Peel/Model/BulkRemovalPlan.swift@@ -52,7 +52,11 @@ final class BulkRemovalPlan {/// What a confirmation would ask about now: the selection, with the sizes this scan measured.var request: RemovalRequest {- RemovalRequest(urls: selectedURLs, sizes: [URL: Int64](measured: selectedURLs.map { ($0, measuredSizes[$0]) }))+ RemovalRequest(+ urls: selectedURLs,+ sizes: [URL: Int64](measured: selectedURLs.map { ($0, measuredSizes[$0]) }),+ sharingStorage: Set(items.filter(\.sharesStorage).map(\.url))+ )}var total: SizeTotal { bulk?.total ?? SizeTotal(known: 0, isComplete: true) }@@ -129,7 +133,12 @@ final class BulkRemovalPlan {}/// Records `result` in History, what moved named by the apps it belonged to and what stayed by its own apps.- func record(_ result: TrashResult, sizes: [URL: Int64], in history: RemovalHistoryStore) async {+ func record(+ _ result: TrashResult,+ sizes: [URL: Int64],+ sharingStorage: Set<URL>,+ in history: RemovalHistoryStore+ ) async {var removal = RemovalInProgress()let moved = bulk?.apps(owning: result.trashed.map(\.originalURL)) ?? []let stayed = bulk?.apps(owning: result.failures.map(\.url)) ?? []@@ -140,7 +149,7 @@ final class BulkRemovalPlan {(TrashResult(failures: result.failures), part(naming: stayed)),]for (result, part) in parts {- await history.record(result, part: part, sizes: sizes, in: &removal)+ await history.record(result, part: part, sizes: sizes, sharingStorage: sharingStorage, in: &removal)}history.finish(removal)}diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swiftindex 3869e1d5..7ad913dc 100644--- a/Peel/Model/RemovalHistoryStore.swift+++ b/Peel/Model/RemovalHistoryStore.swift@@ -197,13 +197,15 @@ final class RemovalHistoryStore {tool: Tool,source: String,sourceKey: String? = nil,- sizes: [URL: Int64]+ sizes: [URL: Int64],+ sharingStorage: Set<URL> = []) async {var removal = RemovalInProgress()await record(result,part: RemovalPart(source: source, sourceKey: sourceKey, tool: tool.rawValue),sizes: sizes,+ sharingStorage: sharingStorage,in: &removal)finish(removal)@@ -214,11 +216,12 @@ final class RemovalHistoryStore {_ result: TrashResult,part: RemovalPart,sizes: [URL: Int64],+ sharingStorage: Set<URL> = [],in removal: inout RemovalInProgress) async {// History first: it is the way back for what just moved, and nothing that follows may keep it unwritten.if !result.trashed.isEmpty {- let new = part.records(of: result, sizes: sizes, batch: removal.batch)+ let new = part.records(of: result, sizes: sizes, sharingStorage: sharingStorage, batch: removal.batch)removal.records += newawait apply(await log.add(new))}diff --git a/Peel/Model/RemovalPlan.swift b/Peel/Model/RemovalPlan.swiftindex 7ffe5940..48f9514e 100644--- a/Peel/Model/RemovalPlan.swift+++ b/Peel/Model/RemovalPlan.swift@@ -85,14 +85,18 @@ final class RemovalPlan {/// What a confirmation would ask about now: the selection, with the sizes this scan measured.var request: RemovalRequest {- RemovalRequest(urls: selectedURLs, sizes: [URL: Int64](measured: selectedURLs.map { url in- (- url,- url == app.url- ? (isAppMeasured ? appSize : nil)- : leftoverSizes[url].flatMap { $0.isMeasured ? $0.size : nil }- )- }))+ RemovalRequest(+ urls: selectedURLs,+ sizes: [URL: Int64](measured: selectedURLs.map { url in+ (+ url,+ url == app.url+ ? (isAppMeasured ? appSize : nil)+ : leftoverSizes[url].flatMap { $0.isMeasured ? $0.size : nil }+ )+ }),+ sharingStorage: appSharesStorage ? [app.url] : []+ )}var privilegedURLs: Set<URL> { uninstallation?.privilegedURLs ?? [] }diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 91f7ac42..8224c2b9 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -491,7 +491,10 @@ struct AppDetailView: View {) {home.record(appManagement: state)}- await history.record(result, tool: .applications, source: plan.app.name, sizes: request.sizes)+ await history.record(+ result, tool: .applications, source: plan.app.name, sizes: request.sizes,+ sharingStorage: request.sharingStorage+ )return result}}diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swiftindex 457186f0..db70e126 100644--- a/Peel/Views/History/HistoryDetailView.swift+++ b/Peel/Views/History/HistoryDetailView.swift@@ -261,10 +261,12 @@ private enum RecordPlace {}private enum RecordNote {+ case sharedStoragecase loadsAfterARestartvar text: LocalizedStringResource {switch self {+ case .sharedStorage: "It shared most of its storage with another copy, so moving it freed only its own part."case .loadsAfterARestart: "Once put back, macOS loads this audio driver only after you restart your Mac."}}@@ -318,7 +320,9 @@ private struct HistoryRecordRow: View {@available(macOS 27, *)private var notes: [RecordNote] {- place == .inTrash && AudioDrivers.isOne(record.originalURL) ? [.loadsAfterARestart] : []+ var notes: [RecordNote] = record.sharedStorage == true ? [.sharedStorage] : []+ if place == .inTrash, AudioDrivers.isOne(record.originalURL) { notes.append(.loadsAfterARestart) }+ return notes}private var item: some View {diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swiftindex b778e531..32ec34f7 100644--- a/Peel/Views/MultipleAppsView.swift+++ b/Peel/Views/MultipleAppsView.swift@@ -372,7 +372,7 @@ struct MultipleAppsView: View {) {home.record(appManagement: state)}- await plan.record(result, sizes: request.sizes, in: history)+ await plan.record(result, sizes: request.sizes, sharingStorage: request.sharingStorage, in: history)return result}}