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.

A row Peel can't take says why on its badge

Țugui Dragoșec6b22b4a08e
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 2aa9a593..e915ac8e 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -76,9 +76,11 @@ public enum HoldBack: String, Sendable, Hashable {
/// An update whose app is running, which may install it when it quits.
case appIsRunning
- /// True when the item cannot be selected at all, rather than only left unselected.
+ /// True when the item cannot be selected at all, rather than only left unselected: the guard or the helper
+ /// would refuse to move it.
public var cannotBeMoved: Bool {
self == .holdsDocuments || self == .holdsALibrary || self == .holdsKeys || self == .beyondTheHelper
+ || self == .holdsAnExclusion
}
/// Why what a walk saw leaves a folder to be chosen by hand: a wallet, a signing key, or a repository inside may
@@ -207,16 +209,11 @@ public struct LeftoverScan: Sendable {
public var cutShortLocations: [SearchLocation] = []
/// Holds back, as `beyondTheHelper`, each item that needs an administrator and that the helper would refuse
- /// once `app` has moved. An item already held back by `holdsAnExclusion`, or by a reason that blocks the move,
- /// keeps its reason.
+ /// once `app` has moved. An item already held back by a reason that blocks the move keeps its reason.
func holdingBack(beyond reach: HelperReach, leaving app: URL) -> LeftoverScan {
LeftoverScan(
leftovers: leftovers.map { leftover in
- let heldBack = leftover.match.heldBack
- guard
- leftover.requiresPrivileges, heldBack != .holdsAnExclusion,
- reach.isBeyond(leftover.url, leaving: app)
- else { return leftover }
+ guard leftover.requiresPrivileges, reach.isBeyond(leftover.url, leaving: app) else { return leftover }
return leftover.heldBack(.beyondTheHelper)
},
unreadableLocations: unreadableLocations,
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
index 523845f7..7464352f 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
@@ -177,8 +177,7 @@ public struct Uninstallation: Sendable {
public func selectable(canUseHelper: Bool) -> Set<URL> {
guard !isExcluded, !isPeel else { return [] }
var urls = Set(scan.leftovers.filter { leftover in
- leftover.match.heldBack != .holdsAnExclusion && leftover.match.heldBack?.cannotBeMoved != true
- && (canUseHelper || !leftover.requiresPrivileges)
+ leftover.match.heldBack?.cannotBeMoved != true && (canUseHelper || !leftover.requiresPrivileges)
}.map(\.url))
if !app.isSystemProtected, !isAppBeyondTheHelper, !isAppInTheTrash, canUseHelper || !appRequiresPrivileges {
urls.insert(app.url)
@@ -205,7 +204,7 @@ public struct Uninstallation: Sendable {
public func movable(among leftovers: [Leftover], withApp: Bool) -> (count: Int, size: SizeTotal) {
guard !isPeel else { return (0, SizeTotal([])) }
var sizes: [Int64?] = leftovers
- .filter { $0.match.heldBack?.cannotBeMoved != true && $0.match.heldBack != .holdsAnExclusion }
+ .filter { $0.match.heldBack?.cannotBeMoved != true }
.map { $0.isMeasured ? $0.size : nil }
if withApp, !app.isSystemProtected, !isExcluded, !isAppBeyondTheHelper, !isAppInTheTrash {
sizes.append(isAppMeasured ? appSize : nil)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 4e5dd3f9..b90bc041 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -645,6 +645,7 @@ struct LeftoverScannerTests {
let found = try #require(scan.leftovers.first { $0.url.lastPathComponent == "Tunewell" })
#expect(found.match.heldBack == .holdsAnExclusion)
+ #expect(found.match.heldBack?.cannotBeMoved == true, "the guard refuses a folder holding an exclusion")
#expect(!found.isMeasured, "a folder nobody measured was given a size of zero")
}
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 7bcd176d..abfc4c8a 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -567,7 +567,6 @@ struct AppDetailView: View {
size: leftover.size,
isMeasured: leftover.isMeasured,
isLocked: leftover.requiresPrivileges && !helper.canAct,
- isExcluded: leftover.match.heldBack == .holdsAnExclusion,
isLeftAlone: leftover.match.heldBack?.cannotBeMoved == true || plan.isPeel,
selection: plan, isSelected: plan.isSelected(leftover.url)
)
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index 92d8adea..f14fb83a 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -202,7 +202,7 @@ struct MultipleAppsView: View {
size: item.size,
isMeasured: item.isMeasured,
isLocked: item.requiresPrivileges && !helper.canAct,
- isExcluded: item.isExcluded,
+ isExcluded: item.isApplication && item.isExcluded,
isLeftAlone: item.match?.heldBack?.cannotBeMoved == true || item.isBeyondTheHelper || (item.isApplication && item.isKeptByMacOS)
|| item.isPeels || item.isInTheTrash,
appIdentifier: item.isApplication ? item.apps.first : nil,
diff --git a/Peel/Views/RemovalRow.swift b/Peel/Views/RemovalRow.swift
index bbc1f341..3c11865e 100644
--- a/Peel/Views/RemovalRow.swift
+++ b/Peel/Views/RemovalRow.swift
@@ -188,7 +188,7 @@ struct RemovalRow: View {
private var badgeKind: (title: LocalizedStringResource, symbol: String)? {
if isExcluded { return ("Excluded in Settings", "hand.raised.fill") }
if isLeftAlone { return ("Left alone", "hand.raised") }
- if isLocked { return ("Helper", "lock.fill") }
+ if isLocked { return ("Needs administrator access", "lock.fill") }
return nil
}
@@ -196,12 +196,7 @@ struct RemovalRow: View {
private var badge: some View {
Group {
if let badgeKind {
- if isLocked, !isExcluded, !isLeftAlone {
- Badge(title: Text(badgeKind.title), systemImage: badgeKind.symbol)
- .help(Text("Needs administrator access"))
- } else {
- Badge(title: Text(badgeKind.title), systemImage: badgeKind.symbol)
- }
+ Badge(title: Text(badgeKind.title), systemImage: badgeKind.symbol)
}
}
.fixedSize()