Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say at the head of an orphan group why nothing in it can move

Țugui Dragoșee2ce67d6d19
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index d241c82a..999e7ce1 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -93227,6 +93227,112 @@
}
}
},
+ "Nothing here can be moved. Each file’s note says why." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nic z této skupiny nelze přesunout. Důvod uvádí poznámka u každého souboru."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nichts hiervon kann verschoben werden. Der Hinweis zu jeder Datei nennt den Grund."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aquí no se puede trasladar nada a la papelera. La nota de cada archivo indica por qué."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rien ici ne peut être déplacé. La note de chaque fichier indique pourquoi."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Qui non si può spostare nulla. La nota di ogni file spiega perché."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ここにあるものは、どれもゴミ箱に入れられません。理由は各ファイルの説明に示されています。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "여기에서 이동할 수 있는 항목이 없습니다. 이유는 각 파일의 설명에서 확인할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niets hier kan worden verplaatst. In de toelichting bij elk bestand staat waarom."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niczego tu nie można przenieść do Kosza. Objaśnienie przy każdym pliku podaje powód."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nada aqui pode ser movido. A nota de cada arquivo diz por quê."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nimic de aici nu poate fi mutat. Informațiile fiecărui fișier explică de ce."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Отсюда ничего нельзя переместить в Корзину. Причина указана в пояснении к каждому файлу."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inget här kan flyttas. Förklaringen vid varje fil anger varför."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Buradaki hiçbir şey taşınamaz. Her dosyanın notu nedenini açıklar."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Тут нічого не можна перемістити. Причину вказано в примітці до кожного файлу."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "此处没有可以移动的内容。每个文件的说明中都注明了原因。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "這裡沒有可移動的項目。每個檔案的附註都會說明原因。"
+ }
+ }
+ }
+ },
"Nothing in here can be moved now." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
index 2c3f36ec..14aea984 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
@@ -66,6 +66,17 @@ public struct OrphanGroup: Sendable, Hashable, Identifiable {
return app
}
+ /// True when nothing in the group can be moved, every item being left alone.
+ public var isLeftAlone: Bool {
+ items.allSatisfy { $0.leftAlone != nil }
+ }
+
+ /// The reason every item is left alone for, when they all share one.
+ public var sharedReason: HoldBack? {
+ guard let reason = items.first?.leftAlone, items.allSatisfy({ $0.leftAlone == reason }) else { return nil }
+ return reason
+ }
+
/// Peel recommends no row it held back, and nothing in a group something may still use: such rows wait to be
/// chosen by hand, as Review Before Removing does on an app's page.
public func selectableRows(canUseHelper: Bool) -> SelectableRows<URL> {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/MovableTotalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/MovableTotalTests.swift
index dbcb0cd3..caa61807 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/MovableTotalTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/MovableTotalTests.swift
@@ -20,6 +20,25 @@ struct MovableTotalTests {
#expect(group.movable == SizeTotal(known: 10, isComplete: true))
}
+ @Test func anOrphanGroupKnowsWhyNothingInItCanMove() {
+ let item = { (name: String, heldBack: HoldBack?) in
+ var item = OrphanItem(
+ url: URL(filePath: "/Users/x/Library/Containers/\(name)"), kind: .containers, size: 10,
+ modificationDate: nil, requiresPrivileges: false
+ )
+ item.heldBack = heldBack
+ return item
+ }
+ let group = { (items: [OrphanItem]) in OrphanGroup(identifier: "org.example.gone", items: items) }
+ let documents = group([item("org.example.gone", .holdsDocuments), item("org.example.gone.share", .holdsDocuments)])
+ let mixed = group([item("org.example.gone", .holdsDocuments), item("org.example.gone.share", .holdsALibrary)])
+ let oneMoves = group([item("org.example.gone", .holdsDocuments), item("org.example.gone.share", .notMeasured)])
+
+ #expect(documents.isLeftAlone && documents.sharedReason == .holdsDocuments)
+ #expect(mixed.isLeftAlone && mixed.sharedReason == nil)
+ #expect(!oneMoves.isLeftAlone && oneMoves.sharedReason == nil)
+ }
+
@Test func aReceiptCountsOnlyWhatCanMove() {
var tool = PackageReceipt.Item(
url: URL(filePath: "/usr/local/bin/org.example.tool"), size: 500, requiresPrivileges: true
diff --git a/Peel/Views/Orphans/OrphanDetailView.swift b/Peel/Views/Orphans/OrphanDetailView.swift
index 211e0ed4..a92ddc97 100644
--- a/Peel/Views/Orphans/OrphanDetailView.swift
+++ b/Peel/Views/Orphans/OrphanDetailView.swift
@@ -76,6 +76,14 @@ struct OrphanDetailView: View {
return lines.isEmpty ? nil : lines.joined(separator: "\n\n")
}
+ private var whyNothingMoves: String? {
+ guard group.isLeftAlone else { return nil }
+ guard let reason = group.sharedReason else {
+ return String(localized: "Nothing here can be moved. Each file’s note says why.")
+ }
+ return String(localized: reason.explanation)
+ }
+
private var header: some View {
PageHeader(systemImage: "questionmark.folder") {
Text(verbatim: group.title)
@@ -107,6 +115,18 @@ struct OrphanDetailView: View {
.font(.callout)
.foregroundStyle(.secondary)
}
+ if #available(macOS 27, *), let why = whyNothingMoves {
+ Text(verbatim: why)
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ let documents = group.items.filter { $0.leftAlone == .holdsDocuments }.map(\.url)
+ if !documents.isEmpty {
+ Button("Show in Finder", systemImage: "folder") {
+ NSWorkspace.shared.activateFileViewerSelecting(documents)
+ }
+ }
+ }
} trailing: {
TotalLabel(total: group.movable, caption: Text("to remove"))
.accessibilityLabel(Text("\(group.movable.text) can be moved to the Trash"))