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
An orphan group written after its app left is no longer called certain
Țugui Dragoșe528f3eb7b35
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 2c572277..e277c3c4 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -100823,6 +100823,118 @@}}},+ "Something wrote here %@, after Peel last saw %@ installed" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Něco sem zapsalo %@, poté co Peel naposledy viděl aplikaci %@ nainstalovanou"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Hier wurde %@ etwas geschrieben, nachdem Peel „%@“ zuletzt installiert vorgefunden hatte"+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "Something wrote here %1$@, after Peel last saw %2$@ installed"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Algo escribió aquí %@, después de que Peel viera %@ instalada por última vez"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Quelque chose a écrit ici %@, après que Peel a vu %@ installé pour la dernière fois"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Qualcosa ha scritto qui %@, dopo l’ultima volta che Peel ha visto %@ installata"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelが最後に“%2$@”のインストールを確認した後、%1$@、ここに書き込みがありました"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel이 ‘%2$@’의 설치를 마지막으로 확인한 후, %1$@ 무언가가 여기에 기록함"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Hier is %@ nog iets geschreven, nadat Peel %@ voor het laatst geïnstalleerd zag"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Coś zapisało tu dane %@, po tym, jak Peel ostatnio widział zainstalowaną aplikację %@"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Algo gravou aqui %@, depois que o Peel viu %@ instalado pela última vez"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ceva a scris aici %@, după ce Peel a văzut ultima dată aplicația %@ instalată"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Сюда что-то записывалось %@, после того как Peel последний раз видел приложение «%@» установленным"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Något skrev här %@, efter att Peel senast såg %@ installerad"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel %2$@ uygulamasını en son yüklü olarak gördükten sonra, buraya %1$@ bir şey yazıldı"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Щось записувало сюди %@, після того як Peel востаннє бачила програму «%@» інстальованою"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "有程序在%@写入过这里,是在Peel上次看到“%@”已安装之后"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%@曾有項目寫入此處,是在Peel最後一次看到「%@」已安裝之後"+ }+ }+ }+ },"Sort By" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex f8e29d30..16760398 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -298,6 +298,7 @@ extension OrphanConfidence {case .running: "something with this identifier is running now"case .leadsIntoAnAppThatIsGone: "these links lead into an app that is no longer there"case .writtenRecently(let date): "something wrote here on \(Output.day(date))"+ case .writtenAfterItLeft(let name, let written): "something wrote here on \(Output.day(written)), after Peel last saw \(name) installed"case .sameMakerStillInstalled: "an app from the same maker is still installed"case .appLeft(let name, let lastSeen): "Peel last saw \(name) installed on \(Output.day(lastSeen))"case .untouched(let months): "\(months) months since anything wrote here"diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swiftindex ef54a552..bb6d771e 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift@@ -6,13 +6,13 @@ public import Foundation/// only decides how a row reads and which rows are listed first.public struct OrphanConfidence: Sendable, Hashable {public enum Level: Int, Sendable, Hashable, Comparable {- /// Something may still use the files: it is running, it wrote here recently, or another app by the same- /// maker is installed.+ /// Something may still use the files: it is running, it wrote here recently or after the app was gone, or+ /// another app by the same maker is installed.case unsure/// Nothing installed claims it.case likely- /// Nothing claims it, and Peel knows why: it saw the app go, nothing has written here in months, or the- /// files are links into an app that is gone.+ /// Nothing claims it, and Peel knows why: it saw the app go and nothing wrote here after, nothing has+ /// written here in months, or the files are links into an app that is gone.case certainpublic static func < (one: Level, other: Level) -> Bool { one.rawValue < other.rawValue }@@ -25,6 +25,9 @@ public struct OrphanConfidence: Sendable, Hashable {case untouched(months: Int)/// Something wrote here within the last week, so something may still be running.case writtenRecently(Date)+ /// Something wrote here after Peel last saw the app, later than its removal takes, so something may still+ /// use the files: the app itself from another disk, or another program.+ case writtenAfterItLeft(name: String, written: Date)/// An app by the same maker is still installed, and apps by one maker can share group folders.case sameMakerStillInstalled/// Something with this identifier is running right now.@@ -77,17 +80,17 @@ public struct OrphanConfidence: Sendable, Hashable {return OrphanConfidence(level: .unsure, reasons: [.sameMakerStillInstalled])}- var reasons: [Reason] = []- if let app = group.rememberedApp {- reasons.append(.appLeft(name: app.name, lastSeen: app.lastSeen))- }if let months = monthsUntouched(group, now: now), months >= longUntouched {- reasons.append(.untouched(months: months))+ return OrphanConfidence(level: .certain, reasons: [.untouched(months: months)])}- guard !reasons.isEmpty else {+ guard let app = group.rememberedApp else {return OrphanConfidence(level: .likely, reasons: [.nothingClaimsIt])}- return OrphanConfidence(level: .certain, reasons: reasons)+ // Peel saw the app go, and something wrote here later than its removal takes, or when is not known.+ if let written = lastWrite(in: group), written <= now {+ return OrphanConfidence(level: .unsure, reasons: [.writtenAfterItLeft(name: app.name, written: written)])+ }+ return OrphanConfidence(level: .likely, reasons: [.appLeft(name: app.name, lastSeen: app.lastSeen)])}/// Whether two identifiers belong to one app. A helper runs under its app's identifier or a longer one. Adiff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swiftindex ce91b690..dd227958 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift@@ -105,6 +105,40 @@ struct OrphanConfidenceTests {#expect(judged.reasons.contains { if case .appLeft(let name, _) = $0 { name == "Numi" } else { false } })}+ @Test("Something that wrote here weeks after the app was gone may still use the files, and the write is the reason")+ func aWriteWeeksAfterTheAppLeft() {+ let judged = OrphanConfidence.judge(group(written: 20 * 24 * 60 * 60, remembered: left("Numi", daysAgo: 60)), now: now)+ #expect(judged.level == .unsure)+ #expect(judged.reasons == [.writtenAfterItLeft(name: "Numi", written: now.addingTimeInterval(-20 * 24 * 60 * 60))])+ }++ @Test("Months of nothing touching it settle it even when something wrote after the app was gone")+ func aWriteAfterTheAppLeftLongAgo() throws {+ let judged = OrphanConfidence.judge(group(written: 250 * 24 * 60 * 60, remembered: left("Numi", daysAgo: 400)), now: now)+ #expect(judged.level == .certain)+ #expect(judged.reasons.count == 1)+ guard case .untouched(let months) = try #require(judged.reasons.first) else {+ Issue.record("expected the months without a write to be the reason, got \(judged.reasons)")+ return+ }+ #expect(months >= OrphanConfidence.longUntouched)+ }++ @Test("Files that were not read in time say nothing about when they were written, so seeing the app go is not enough")+ func aGoneAppWhoseFilesWereNotRead() {+ let item = OrphanItem(+ url: URL(filePath: "/Users/someone/Library/Application Support/com.example.app", directoryHint: .isDirectory),+ kind: .applicationSupport,+ size: nil,+ modificationDate: now.addingTimeInterval(-400 * 24 * 60 * 60),+ requiresPrivileges: false+ )+ let numi = left("Numi")+ let judged = OrphanConfidence.judge(OrphanGroup(identifier: "com.example.app", items: [item], rememberedApp: numi), now: now)+ #expect(judged.level == .likely)+ #expect(judged.reasons == [.appLeft(name: "Numi", lastSeen: numi.lastSeen)])+ }+@Test("Months of nothing touching it is enough on its own")func longUntouched() {let judged = OrphanConfidence.judge(group(written: 400 * 24 * 60 * 60), now: now)@@ -150,6 +184,9 @@ struct OrphanConfidenceTests {func aClockThatRanAhead() {let judged = OrphanConfidence.judge(group(written: -10 * 24 * 60 * 60), now: now)#expect(judged.level == .likely)+ // Nor as the removal of an app Peel saw go: that write would have to come before it.+ let afterTheApp = OrphanConfidence.judge(group(written: -10 * 24 * 60 * 60, remembered: left("Numi")), now: now)+ #expect(afterTheApp.level == .likely)}@Test("What Peel is sure about is listed first, and the largest of those first again")diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swiftindex c10698ee..886e29f6 100644--- a/Peel/Views/Orphans/OrphanList.swift+++ b/Peel/Views/Orphans/OrphanList.swift@@ -89,11 +89,11 @@ private struct OrphanGroupRow: View {.lineLimit(1).truncationMode(.middle)}- // Shows why Peel thinks nothing uses these files, not a date the user would have to interpret.+ // Shows why Peel thinks nothing uses these files, not a date the user would have to interpret. It is+ // shown whole, since the app's name can come last.group.confidence.summary.font(.caption).rowTint(group.confidence.tint)- .lineLimit(2)}Spacer(minLength: 6)Text(group.total.text)diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 0b483667..16b76bfa 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -209,12 +209,18 @@ extension OrphanConfidence {}/// The badge on a group's page, or nil when it would add nothing: the summary when Peel is unsure, or- /// else how long nothing has written there. That Peel saw the app leave is said in a line of its own.+ /// else how long nothing has written there. That Peel saw the app leave is said in a line of its own, so a+ /// write after it left is told by its date alone.var badge: Text? {+ if case .writtenAfterItLeft(_, let written) = reasons.first { return wroteHere(written) }if level == .unsure { return summary }return reasons.first { if case .untouched = $0 { true } else { false } }.map(text(for:))}+ private func wroteHere(_ date: Date) -> Text {+ Text("Something wrote here \(date, format: .relative(presentation: .named))")+ }+private func text(for reason: Reason?) -> Text {guard let reason else { return Text("No installed app claims these") }return switch reason {@@ -223,7 +229,9 @@ extension OrphanConfidence {case .leadsIntoAnAppThatIsGone:Text("These links lead into an app that is no longer there")case .writtenRecently(let date):- Text("Something wrote here \(date, format: .relative(presentation: .named))")+ wroteHere(date)+ case .writtenAfterItLeft(let name, let written):+ Text("Something wrote here \(written, format: .relative(presentation: .named)), after Peel last saw \(name) installed")case .sameMakerStillInstalled:Text("An app from the same maker is still installed")case .appLeft(let name, let lastSeen):