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
Space says when it could not learn the snapshots or purgeable space
Țugui Dragoșe72437edb2e4
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 7436bc61..95c33aed 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -85612,6 +85612,218 @@}}},+ "Peel couldn’t find out how much of the available space macOS clears by itself." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nemohl zjistit, kolik z dostupného místa macOS uvolní sám."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel konnte nicht ermitteln, wie viel vom verfügbaren Speicherplatz macOS selbst freigibt."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel no ha podido averiguar cuánto del espacio disponible libera macOS por su cuenta."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel n’a pas pu déterminer quelle part de l’espace disponible macOS libère de lui-même."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel non è riuscito a scoprire quanta parte dello spazio disponibile macOS libera da solo."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelは、使用可能な領域のうちmacOSが自動的に消去する量を調べられませんでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel이 사용 가능한 공간 중 macOS가 스스로 비우는 공간의 양을 알아낼 수 없었습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kon niet nagaan hoeveel van de beschikbare ruimte macOS zelf opruimt."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nie mógł ustalić, ile dostępnego miejsca macOS zwalnia sam."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Peel não conseguiu descobrir quanto do espaço disponível o macOS libera sozinho."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nu a putut afla cât din spațiul disponibil eliberează macOS singur."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не удалось узнать, какую часть доступного пространства macOS очищает сама."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kunde inte ta reda på hur mycket av det tillgängliga utrymmet som macOS frigör på egen hand."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel, kullanılabilir alanın ne kadarını macOS’in kendiliğinden temizlediğini öğrenemedi."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не вдалося зʼясувати, скільки доступного місця macOS очищає сама."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel未能查明可用空间中有多少是macOS会自行清除的。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel無法得知可用空間中有多少是macOS會自行清除的。"+ }+ }+ }+ },+ "Peel couldn’t list the snapshots kept on this disk, which may hold some of its space." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nemohl vypsat snímky uložené na tomto disku, které mohou zabírat část jeho místa."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel konnte die Snapshots nicht auflisten, die auf diesem Volume gespeichert sind und möglicherweise einen Teil des Speicherplatzes belegen."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel no ha podido obtener la lista de las instantáneas guardadas en este disco, que pueden ocupar parte de su espacio."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel n’a pas pu répertorier les instantanés conservés sur ce disque, qui peuvent occuper une partie de son espace."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel non è riuscito a elencare le istantanee conservate su questo disco, che potrebbero occupare parte del suo spazio."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelは、このディスクに保存されているスナップショットを一覧にできませんでした。スナップショットがこのディスクの領域の一部を占めている可能性があります。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel이 이 디스크에 보관된 스냅샷을 나열할 수 없었습니다. 이 스냅샷이 디스크 공간의 일부를 차지하고 있을 수 있습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kon de momentopnamen die op deze schijf worden bewaard niet opvragen, en die kunnen een deel van de schijfruimte innemen."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nie mógł odczytać listy migawek przechowywanych na tym dysku, które mogą zajmować część jego miejsca."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Peel não conseguiu listar as capturas guardadas neste disco, que podem ocupar parte do seu espaço."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nu a putut lista instantaneele păstrate pe acest disc, care pot ocupa o parte din spațiul său."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не удалось получить список снимков, хранящихся на этом диске, а они могут занимать часть его пространства."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kunde inte lista ögonblicksbilderna som sparas på den här skivan, och de kan ta upp en del av dess utrymme."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel, bu diskte tutulan ve diskin alanının bir kısmını kaplıyor olabilecek anlık görüntüleri listeleyemedi."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не вдалося отримати список знімків, збережених на цьому диску, які можуть займати частину його місця."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel未能列出存放在此磁盘上的快照,这些快照可能占用了此磁盘的部分空间。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel無法列出保留在此磁碟上的快照,這些快照可能佔用此磁碟的部分空間。"+ }+ }+ }+ },"Peel couldn’t look in ^[%lld folder](inflect: true)" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Space/LocalSnapshots.swift b/Packages/PeelCore/Sources/PeelCore/Space/LocalSnapshots.swiftindex eb38b934..5d428199 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/LocalSnapshots.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/LocalSnapshots.swift@@ -34,19 +34,20 @@ public enum LocalSnapshots {public static let deleteCommand = "tmutil deletelocalsnapshots \(volume)"+ /// The volume's snapshots, or nil when `diskutil` gave no answer Peel can read, which is not a volume with none.@concurrent- public static func list(volume: String = LocalSnapshots.volume) async -> [LocalSnapshot] {+ public static func list(volume: String = LocalSnapshots.volume) async -> [LocalSnapshot]? {let arguments = ["apfs", "listSnapshots", "-plist", volume]guard case .success(let output) = await Subprocess.run("/usr/sbin/diskutil", arguments, timeout: 30),- output.status == 0 else { return [] }+ output.status == 0 else { return nil }return parse(output.standardOutput)}/// Reads what `diskutil apfs listSnapshots -plist` prints: a `Snapshots` array whose entries carry/// `SnapshotName` and, when `diskutil` knows it, `Purgeable`.- static func parse(_ data: Data) -> [LocalSnapshot] {+ static func parse(_ data: Data) -> [LocalSnapshot]? {guard let plist = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any],- let entries = plist["Snapshots"] as? [[String: Any]] else { return [] }+ let entries = plist["Snapshots"] as? [[String: Any]] else { return nil }return entries.compactMap { entry inguard let name = entry["SnapshotName"] as? String else { return nil }let isPurgeable = entry["Purgeable"] as? Booldiff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swiftindex 7729476a..41d68d24 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift@@ -42,11 +42,11 @@ public struct SpaceItem: Sendable, Hashable, Identifiable {public struct SpaceReport: Sendable {public let items: [SpaceItem]public let storage: DeviceInfo.Storage- /// Space macOS can reclaim by itself, mostly local snapshots and caches.- public let purgeable: Int64+ /// Space macOS can reclaim by itself, mostly local snapshots and caches. Nil when the volume did not say.+ public let purgeable: Int64?/// Local snapshots: copies of the disk kept on the disk itself. Peel explains them but never removes one,- /// because deleting a snapshot cannot be undone.- public let snapshots: [LocalSnapshot]+ /// because deleting a snapshot cannot be undone. Nil when `diskutil` did not say.+ public let snapshots: [LocalSnapshot]?/// True when an area went unmeasured because macOS refused access, which Full Disk Access would grant.public let needsFullDiskAccess: Bool@@ -390,10 +390,10 @@ public enum SpaceInventory {)}- static func purgeableSpace(of url: URL) -> Int64 {+ static func purgeableSpace(of url: URL) -> Int64? {let values = try? url.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey, .volumeAvailableCapacityKey])- let important = values?.volumeAvailableCapacityForImportantUsage ?? 0- let free = Int64(values?.volumeAvailableCapacity ?? 0)- return max(0, important - free)+ guard let important = values?.volumeAvailableCapacityForImportantUsage,+ let free = values?.volumeAvailableCapacity else { return nil }+ return max(0, important - Int64(free))}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LocalSnapshotsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LocalSnapshotsTests.swiftindex d4741d69..ba2a82d2 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LocalSnapshotsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LocalSnapshotsTests.swift@@ -39,7 +39,7 @@ struct LocalSnapshotsTests {</plist>"""- let snapshots = LocalSnapshots.parse(Data(output.utf8))+ let snapshots = try #require(LocalSnapshots.parse(Data(output.utf8)))#expect(snapshots.count == 3)let update = try #require(snapshots.first)@@ -82,14 +82,20 @@ struct LocalSnapshotsTests {<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>Snapshots</key><array/></dict></plist>"""- #expect(LocalSnapshots.parse(Data(none.utf8)).isEmpty)- #expect(LocalSnapshots.parse(Data()).isEmpty)- #expect(LocalSnapshots.parse(Data("No snapshots for disk3s1".utf8)).isEmpty)+ #expect(LocalSnapshots.parse(Data(none.utf8))?.isEmpty == true)+ }++ /// An answer that is not the list `-plist` asks for, or no answer at all, leaves the snapshots unknown: never+ /// read as a disk that keeps none, when they may be what holds its space.+ @Test func anAnswerItCannotReadLeavesTheSnapshotsUnknown() async {+ #expect(LocalSnapshots.parse(Data()) == nil)+ #expect(LocalSnapshots.parse(Data("Unable to find disk".utf8)) == nil)+ #expect(await LocalSnapshots.list(volume: "/Volumes/org.example.missing") == nil)}/// Lists the snapshots of the machine running the test. Listing reads and changes nothing.- @Test func readsThisMacWithoutTouchingIt() async {- let snapshots = await LocalSnapshots.list()+ @Test func readsThisMacWithoutTouchingIt() async throws {+ let snapshots = try #require(await LocalSnapshots.list())#expect(Set(snapshots.map(\.id)).count == snapshots.count)}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swiftindex 0b33b5fd..0adf3259 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift@@ -272,6 +272,11 @@ struct SpaceInventoryTests {#expect(checked > 0, "nothing in the table can be emptied, so the test proves nothing")}+ @Test func knowsNoPurgeableSpaceForAVolumeItCannotRead() {+ #expect(SpaceInventory.purgeableSpace(of: URL(filePath: "/Volumes/org.example.missing")) == nil)+ #expect(SpaceInventory.purgeableSpace(of: .homeDirectory) != nil)+ }+/// Scanning the real Mac must work and change nothing. It walks the real home folder, so it runs only when/// asked for (`PEEL_TEST_THIS_MAC=1`).@Test(.enabled(if: ProcessInfo.processInfo.environment["PEEL_TEST_THIS_MAC"] != nil))@@ -279,8 +284,8 @@ struct SpaceInventoryTests {let report = await SpaceInventory.scan()#expect(report.storage.total > 0)#expect(report.storage.free <= report.storage.total)- #expect(report.purgeable <= report.storage.total)- #expect(report.snapshots.allSatisfy { !$0.name.isEmpty })+ #expect((report.purgeable ?? 0) <= report.storage.total)+ #expect(report.snapshots?.allSatisfy { !$0.name.isEmpty } == true)#expect(report.items.allSatisfy { !$0.urls.isEmpty })}}diff --git a/Peel/Views/Space/SpaceList.swift b/Peel/Views/Space/SpaceList.swiftindex 8f285388..63fc79a3 100644--- a/Peel/Views/Space/SpaceList.swift+++ b/Peel/Views/Space/SpaceList.swift@@ -77,15 +77,23 @@ struct SpaceList: View {private func storage(_ report: SpaceReport) -> some View {VStack(alignment: .leading, spacing: 8) {StorageStrip(storage: report.storage)- if report.purgeable > 0 {+ if let purgeable = report.purgeable, purgeable > 0 {// The strip's available figure already includes these bytes, so the note ties them to it, not// to the used figure.- Text("The available space includes \(report.purgeable.byteCount) that macOS clears when something needs the room.")+ Text("The available space includes \(purgeable.byteCount) that macOS clears when something needs the room.")+ .font(.caption)+ .foregroundStyle(.secondary)+ } else if report.purgeable == nil {+ Text("Peel couldn’t find out how much of the available space macOS clears by itself.").font(.caption).foregroundStyle(.secondary)}- if !report.snapshots.isEmpty {- SnapshotNote(snapshots: report.snapshots)+ if let snapshots = report.snapshots, !snapshots.isEmpty {+ SnapshotNote(snapshots: snapshots)+ } else if report.snapshots == nil {+ Text("Peel couldn’t list the snapshots kept on this disk, which may hold some of its space.")+ .font(.caption)+ .foregroundStyle(.secondary)}}.padding(.vertical, 6)