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.

An app already in the Trash leaves only its leftovers to move

Țugui Dragoș40470279288a
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 039049fa..0367ae3e 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -9595,6 +9595,112 @@
}
}
},
+ "Already in the Trash. What it left behind can still go." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aplikace už je v koši. Co po sobě zanechala, lze ještě odstranit."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bereits im Papierkorb. Was die App hinterlassen hat, kann trotzdem verschoben werden."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ya está en la papelera. Lo que ha dejado aún se puede eliminar."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Déjà dans la corbeille. Ce que l’app a laissé derrière elle peut encore être supprimé."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Già nel Cestino. Ciò che si è lasciata dietro può ancora essere rimosso."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "すでにゴミ箱にあります。このアプリが残したものは、まだゴミ箱に入れられます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이미 휴지통에 있습니다. 앱이 남긴 파일은 여전히 휴지통으로 이동할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Staat al in de prullenmand. Wat de app heeft achtergelaten, kan nog steeds weg."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Jest już w Koszu. To, co po sobie pozostawiła, nadal można przenieść do Kosza."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Já está no Lixo. O que ele deixou para trás ainda pode ir para lá."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Deja în Coș. Ce a lăsat în urmă poate fi mutat în continuare."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Уже в Корзине. То, что осталось после него, еще можно переместить в Корзину."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ligger redan i papperskorgen. Det som den lämnade kvar kan fortfarande tas bort."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Uygulama zaten Çöp Sepeti’nde. Geride bıraktığı dosyalar yine de kaldırılabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Уже в Смітнику. Те, що вона залишила по собі, ще можна вилучити."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "已在废纸篓中。它留下的文件仍可移除。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "已在「垃圾桶」中。它留下的檔案仍可移除。"
+ }
+ }
+ }
+ },
"Also reset privacy permissions" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
index 27518f99..2d5ca78a 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
@@ -367,7 +367,7 @@ struct UninstallCommand: AsyncParsableCommand {
let exclusions = await ExclusionStore().load()
try AppLookup.refuseIfExcluded(target, by: exclusions)
let service = TrashService(exclusions: exclusions)
- guard !service.isInATrash(target.url) else {
+ guard !service.isInsideATrash(target.url) else {
throw CommandFailure("\(target.name) is already in the Trash. Empty it, or put it back first.")
}
try await Self.refuseWhileRunning(target, among: apps)
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
index 68482559..04a57e4d 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
@@ -25,11 +25,13 @@ public struct BulkUninstallation: Sendable {
public var isBeyondTheHelper = false
/// Peel or a file of Peel's: Peel is removed only from its own Settings. Shown, never selected, never moved.
public var isPeels = false
+ /// An app's bundle already in the Trash. Shown, never selected, never counted.
+ public var isInTheTrash = false
public var id: URL { url }
public var isApplication: Bool { match == nil }
public var isRecommended: Bool {
- guard !isExcluded, !isPeels, !isKeptByMacOS, !isBeyondTheHelper else { return false }
+ guard !isExcluded, !isPeels, !isKeptByMacOS, !isBeyondTheHelper, !isInTheTrash else { return false }
guard let match else { return true }
return sharedWithOthers.isEmpty && otherCopies.isEmpty && match.confidence >= .likely && match.heldBack == nil
}
@@ -44,7 +46,7 @@ public struct BulkUninstallation: Sendable {
/// as zero: it makes the total incomplete.
public var total: SizeTotal {
SizeTotal(items
- .filter { !$0.isExcluded && !$0.isPeels && !($0.isApplication && $0.isKeptByMacOS) && !$0.isBeyondTheHelper && $0.match?.heldBack?.cannotBeMoved != true }
+ .filter { !$0.isExcluded && !$0.isPeels && !($0.isApplication && $0.isKeptByMacOS) && !$0.isBeyondTheHelper && !$0.isInTheTrash && $0.match?.heldBack?.cannotBeMoved != true }
.map { $0.isMeasured ? $0.size : nil })
}
public var unreadableLocations: [SearchLocation] {
@@ -86,7 +88,7 @@ public struct BulkUninstallation: Sendable {
/// move, and nothing of Peel.
public func selectable(canUseHelper: Bool) -> Set<URL> {
Set(items.filter { item in
- !item.isExcluded && !item.isPeels && !item.isBeyondTheHelper && !(item.isApplication && item.isKeptByMacOS)
+ !item.isExcluded && !item.isPeels && !item.isBeyondTheHelper && !item.isInTheTrash && !(item.isApplication && item.isKeptByMacOS)
&& item.match?.heldBack?.cannotBeMoved != true && (canUseHelper || !item.requiresPrivileges)
}.map(\.url))
}
@@ -98,13 +100,14 @@ public struct BulkUninstallation: Sendable {
}
/// The bundle identifiers of the chosen apps that stay: each one with a copy whose bundle is not selected. That
- /// includes an app that cannot go (`Uninstallation.appStays(canUseHelper:)`), since its bundle never is.
+ /// includes an app that cannot go (`Uninstallation.appStays(canUseHelper:)`), since its bundle never is, and
+ /// leaves out a copy already in the Trash, which stays nowhere.
public func staying(selected: Set<URL>) -> Set<String> {
- Set(uninstallations.filter { !selected.contains($0.app.url) }.map(\.app.bundleIdentifier))
+ Set(uninstallations.filter { !$0.isAppInTheTrash && !selected.contains($0.app.url) }.map(\.app.bundleIdentifier))
}
public var privilegedURLs: Set<URL> {
- Set(items.filter { $0.requiresPrivileges && !$0.isExcluded && !$0.isPeels && !$0.isBeyondTheHelper && !($0.isApplication && $0.isKeptByMacOS) }.map(\.url))
+ Set(items.filter { $0.requiresPrivileges && !$0.isExcluded && !$0.isPeels && !$0.isBeyondTheHelper && !$0.isInTheTrash && !($0.isApplication && $0.isKeptByMacOS) }.map(\.url))
}
/// Returns the selection in the order it is moved: leftovers first, then the apps. Excluded items and Peel's
@@ -135,7 +138,8 @@ public struct BulkUninstallation: Sendable {
isKeptByMacOS: existing.isKeptByMacOS || item.isKeptByMacOS,
isMeasured: existing.isMeasured || item.isMeasured,
isBeyondTheHelper: existing.isBeyondTheHelper || item.isBeyondTheHelper,
- isPeels: existing.isPeels || item.isPeels
+ isPeels: existing.isPeels || item.isPeels,
+ isInTheTrash: existing.isInTheTrash || item.isInTheTrash
)
} else {
byURL[item.url] = item
@@ -174,7 +178,8 @@ public struct BulkUninstallation: Sendable {
isKeptByMacOS: uninstallation.app.isSystemProtected,
isMeasured: uninstallation.isAppMeasured,
isBeyondTheHelper: uninstallation.isAppBeyondTheHelper,
- isPeels: uninstallation.isPeel
+ isPeels: uninstallation.isPeel,
+ isInTheTrash: uninstallation.isAppInTheTrash
))
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
index 8dcd854a..73970186 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
@@ -410,15 +410,28 @@ public struct TrashService: Sendable {
/// folder is compared with links resolved, since one that is only called `.Trash` can be a link into
/// Messages. `FileManager` is not asked: for a folder in iCloud Drive it names iCloud's Trash, not Peel's.
public func isInATrash(_ url: URL) -> Bool {
- guard
- !url.pathComponents.contains(where: { $0 == "." || $0 == ".." }),
- let folder = PrivilegedPathPolicy.resolvedPath(url.deletingLastPathComponent().path(percentEncoded: false))
- else { return false }
+ guard let folder = resolvedFolder(of: url) else { return false }
+ return trashes(forItemsIn: folder).contains(folder)
+ }
+
+ /// Whether `url` is in a Trash, directly or in a folder there, where nothing can be moved again.
+ public func isInsideATrash(_ url: URL) -> Bool {
+ guard let folder = resolvedFolder(of: url) else { return false }
+ return trashes(forItemsIn: folder).contains { PathComponents.isPath(folder, atOrInside: $0) }
+ }
+
+ private func resolvedFolder(of url: URL) -> String? {
+ guard !url.pathComponents.contains(where: { $0 == "." || $0 == ".." }) else { return nil }
+ return PrivilegedPathPolicy.resolvedPath(url.deletingLastPathComponent().path(percentEncoded: false))
+ }
+
+ /// The Trashes an item in `folder` could be in, with links resolved: the home's, and its volume's.
+ private func trashes(forItemsIn folder: String) -> [String] {
var trashes = [URL.homeDirectory, environment.homeDirectory].map { $0.appending(path: ".Trash", directoryHint: .isDirectory) }
if let volume = try? URL(filePath: folder).resourceValues(forKeys: [.volumeURLKey]).volume {
trashes.append(volume.appending(path: ".Trashes/\(getuid())", directoryHint: .isDirectory))
}
- return trashes.contains { PrivilegedPathPolicy.resolvedPath($0.path(percentEncoded: false)) == folder }
+ return trashes.compactMap { PrivilegedPathPolicy.resolvedPath($0.path(percentEncoded: false)) }
}
/// The failure reason for an error a move threw. macOS does not say which permission is missing, so any
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
index 2a36b30d..523845f7 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
@@ -14,6 +14,9 @@ public struct Uninstallation: Sendable {
/// True when the app needs administrator rights and the helper may not move it. The app is then never
/// selected: its leftovers would move first, and the app would stay without them.
public var isAppBeyondTheHelper = false
+ /// True when the app is already in the Trash, where Watch the Trash finds it: its bundle can't move again, so
+ /// it is never selected or counted, and what it left behind still is.
+ public var isAppInTheTrash = false
/// True for Peel, which is removed only from its own Settings, where its helper and login item go first. Its
/// files are listed, and nothing of it is selected or moved anywhere else: `unreviewedSelection` is that way.
public var isPeel: Bool { app.isPeelItself }
@@ -54,7 +57,8 @@ public struct Uninstallation: Sendable {
appRequiresPrivileges: appRequiresPrivileges,
scan: scan,
isAppMeasured: await bundle.map { !$0.couldNotBeRead } ?? false,
- isAppBeyondTheHelper: appRequiresPrivileges && !app.isSystemProtected && reach.isBeyond(app.url)
+ isAppBeyondTheHelper: appRequiresPrivileges && !app.isSystemProtected && reach.isBeyond(app.url),
+ isAppInTheTrash: TrashService(environment: environment).isInsideATrash(app.url)
)
}
@@ -162,7 +166,9 @@ public struct Uninstallation: Sendable {
public func suggestedSelection(canUseHelper: Bool) -> Set<URL> {
guard !appStays(canUseHelper: canUseHelper) else { return [] }
var selection = Set(scan.leftovers.filter { $0.match.isRecommended && (canUseHelper || !$0.requiresPrivileges) }.map(\.url))
- selection.insert(app.url)
+ if !isAppInTheTrash {
+ selection.insert(app.url)
+ }
return selection
}
@@ -174,7 +180,7 @@ public struct Uninstallation: Sendable {
leftover.match.heldBack != .holdsAnExclusion && leftover.match.heldBack?.cannotBeMoved != true
&& (canUseHelper || !leftover.requiresPrivileges)
}.map(\.url))
- if !app.isSystemProtected, !isAppBeyondTheHelper, canUseHelper || !appRequiresPrivileges {
+ if !app.isSystemProtected, !isAppBeyondTheHelper, !isAppInTheTrash, canUseHelper || !appRequiresPrivileges {
urls.insert(app.url)
}
return urls
@@ -201,7 +207,7 @@ public struct Uninstallation: Sendable {
var sizes: [Int64?] = leftovers
.filter { $0.match.heldBack?.cannotBeMoved != true && $0.match.heldBack != .holdsAnExclusion }
.map { $0.isMeasured ? $0.size : nil }
- if withApp, !app.isSystemProtected, !isExcluded, !isAppBeyondTheHelper {
+ if withApp, !app.isSystemProtected, !isExcluded, !isAppBeyondTheHelper, !isAppInTheTrash {
sizes.append(isAppMeasured ? appSize : nil)
}
return (sizes.count, SizeTotal(sizes))
@@ -210,7 +216,7 @@ public struct Uninstallation: Sendable {
public var privilegedURLs: Set<URL> {
guard !isExcluded, !isPeel else { return [] }
var urls = Set(scan.leftovers.filter { $0.requiresPrivileges && $0.match.heldBack != .beyondTheHelper }.map(\.url))
- if appRequiresPrivileges, !app.isSystemProtected, !isAppBeyondTheHelper {
+ if appRequiresPrivileges, !app.isSystemProtected, !isAppBeyondTheHelper, !isAppInTheTrash {
urls.insert(app.url)
}
return urls
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
index 55d7874e..28035b6c 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift
@@ -4,6 +4,24 @@ import Synchronization
import Testing
struct TrashServiceTests {
+ /// An item is in the Trash when it sits there or in a folder there. Put Back asks the narrower question, since
+ /// what it puts back sits directly in a Trash, and a folder that is only called `.Trash` is no Trash.
+ @Test func knowsWhatIsInATrashDirectlyOrInAFolderThere() throws {
+ let directory = try TemporaryDirectory()
+ let service = try service(in: directory)
+ let direct = try directory.directory("home/.Trash/Example.app")
+ let nested = try directory.directory("home/.Trash/Old Apps/Example.app")
+ let installed = try directory.directory("home/Applications/Example.app")
+ let lookalike = try directory.directory("home/Documents/.Trash/Example.app")
+
+ #expect(service.isInsideATrash(direct))
+ #expect(service.isInsideATrash(nested))
+ #expect(!service.isInsideATrash(installed))
+ #expect(!service.isInsideATrash(lookalike))
+ #expect(service.isInATrash(direct))
+ #expect(!service.isInATrash(nested))
+ }
+
private func service(in directory: borrowing TemporaryDirectory) throws -> TrashService {
// Where macOS keeps it, because restore refuses an item that is not really in a Trash.
let trash = try directory.directory("home/.Trash")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
index c230ee81..547dcc45 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
@@ -233,6 +233,33 @@ struct UninstallationTests {
#expect(!plan.isAppMeasured, "an app that could not be read counted as measured, at zero bytes")
}
+ /// Watch the Trash leads to the page of an app already in the Trash, so what it left behind can go too. Its bundle
+ /// can't move again, so it is neither selected nor counted, on its own page or among several apps, and the app
+ /// does not count as one that stays, which would hold its leftovers back.
+ @Test(arguments: ["home/.Trash/Example.app", "home/.Trash/Old Apps/Example.app"])
+ func anAppAlreadyInTheTrashLeavesOnlyItsLeftoversToMove(place: String) async throws {
+ let directory = try TemporaryDirectory()
+ let home = try directory.directory("home")
+ let bundle = try directory.directory(place)
+ try directory.file("\(place)/Contents/Info.plist", bytes: 4_096)
+ try directory.file("home/Library/Preferences/org.example.app.plist")
+ let installed = InstalledApp(url: bundle, bundleIdentifier: "org.example.app", name: "Example")
+ let environment = SearchEnvironment(homeDirectory: home, rootDirectory: directory.url.appending(path: "root"))
+
+ let plan = await Uninstallation.prepare(installed, installedApps: [installed], environment: environment)
+ #expect(plan.isAppInTheTrash)
+ #expect(plan.suggestedSelection(canUseHelper: true).map(\.lastPathComponent) == ["org.example.app.plist"])
+ #expect(!plan.selectable(canUseHelper: true).contains(bundle))
+ #expect(plan.movable(among: plan.scan.leftovers, withApp: true).count == 1)
+ #expect(!plan.privilegedURLs.contains(bundle))
+
+ let several = await BulkUninstallation.prepare([installed], installedApps: [installed], environment: environment)
+ #expect(several.suggestedSelection(canUseHelper: true).map(\.lastPathComponent) == ["org.example.app.plist"])
+ #expect(!several.selectable(canUseHelper: true).contains(bundle))
+ #expect(several.staying(selected: []).isEmpty, "an app already in the Trash held its leftovers back")
+ #expect(several.total == SizeTotal(plan.scan.leftovers.map { $0.isMeasured ? $0.size : nil }))
+ }
+
/// Excluded by identifier or by path, the app and everything the scan would find are left alone.
@Test func leavesAnExcludedAppAndItsFilesAlone() async throws {
let directory = try TemporaryDirectory()
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index 6233d713..5dd6f1aa 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -134,6 +134,9 @@ final class AppLibrary {
/// Apps shown from outside the scanned folders, such as one in Downloads or in the Trash. Kept apart,
/// because the next reading of the folders doesn't find them and would drop their row and their page.
private var revealed: [InstalledApp] = []
+ /// The listed apps that are in a Trash, which only a revealed one can be: Watch the Trash leads to them so what
+ /// they left behind can go. They are on their way out, so no round checks them, and no update is counted.
+ private var appsInATrash: Set<InstalledApp.ID> = []
/// Runs the reading of the folders. A new reading stops one still running, since the older one could
/// finish last with a list that lacks an app installed in between.
let scanRun = ScanRun()
@@ -206,6 +209,8 @@ final class AppLibrary {
@discardableResult
private func adopt(_ found: [InstalledApp]) -> [InstalledApp] {
revealed = stillThere(revealed, beside: found)
+ let trash = TrashService()
+ appsInATrash = Set(revealed.filter { trash.isInsideATrash($0.url) }.map(\.id))
let listed = AppCatalog.sorted(found + revealed)
let previous = Dictionary(apps.map { ($0.id, $0) }, uniquingKeysWith: { first, _ in first })
let changed = listed.filter { app in previous[app.id].map { !Self.isTheSameBuild($0, app) } ?? false }
@@ -428,7 +433,7 @@ final class AppLibrary {
guard UserDefaults.standard.object(forKey: SettingsKey.checksForAppUpdates) as? Bool ?? true else { return }
let now = Date.now
let wanted = targets.filter { app in
- guard !isIgnored(app) else { return false }
+ guard !isIgnored(app), !appsInATrash.contains(app.id) else { return false }
guard !force else { return true }
// Already being checked by another round: a second answer could double the wait for the next check.
guard !appsCheckingForUpdates.contains(app.id) else { return false }
diff --git a/Peel/Model/BulkRemovalPlan.swift b/Peel/Model/BulkRemovalPlan.swift
index 6a872c84..c716b5e5 100644
--- a/Peel/Model/BulkRemovalPlan.swift
+++ b/Peel/Model/BulkRemovalPlan.swift
@@ -54,6 +54,11 @@ final class BulkRemovalPlan {
}
}
+ /// The chosen apps already in the Trash, which neither go nor stay: only what they left behind can move.
+ var appsInTheTrash: Set<URL> {
+ Set(bulk?.uninstallations.filter(\.isAppInTheTrash).map(\.app.url) ?? [])
+ }
+
/// The bundle identifiers of the chosen apps that stay (`BulkUninstallation.staying(selected:)`).
var staying: Set<String> {
bulk?.staying(selected: selectedURLs) ?? []
diff --git a/Peel/Model/RemovalPlan.swift b/Peel/Model/RemovalPlan.swift
index a8f57f79..2548c980 100644
--- a/Peel/Model/RemovalPlan.swift
+++ b/Peel/Model/RemovalPlan.swift
@@ -63,6 +63,10 @@ final class RemovalPlan {
uninstallation?.isAppBeyondTheHelper ?? false
}
+ var isAppInTheTrash: Bool {
+ uninstallation?.isAppInTheTrash ?? false
+ }
+
/// Known before the scan, so the page says from the start that Peel removes itself in Settings.
var isPeel: Bool {
app.isPeelItself
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index f4278650..0fbbb585 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -176,7 +176,7 @@ struct AppDetailView: View {
recommendedSection
reviewSection
- if PrivacyReset.isAllowed(bundleIdentifier: plan.app.bundleIdentifier) {
+ if PrivacyReset.isAllowed(bundleIdentifier: plan.app.bundleIdentifier), !plan.isAppInTheTrash {
PrivacyResetRow(isOn: $resetsPrivacy, detail: PrivacyResetRow.beforeTheMove)
}
defaultsSection
@@ -258,7 +258,7 @@ struct AppDetailView: View {
isMeasured: plan.isAppMeasured,
isLocked: plan.appRequiresPrivileges && !helper.canAct,
isExcluded: plan.isExcluded,
- isLeftAlone: plan.app.isSystemProtected || plan.isAppBeyondTheHelper || plan.isPeel,
+ isLeftAlone: plan.app.isSystemProtected || plan.isAppBeyondTheHelper || plan.isAppInTheTrash || plan.isPeel,
appIdentifier: plan.app.bundleIdentifier,
selection: plan, isSelected: plan.isSelected(plan.app.url)
)
@@ -313,6 +313,9 @@ struct AppDetailView: View {
if plan.app.isSystemProtected {
return String(localized: "macOS keeps this app, so it stays where it is.")
}
+ if plan.isAppInTheTrash {
+ return String(localized: "Already in the Trash. What it left behind can still go.")
+ }
return plan.isAppBeyondTheHelper ? String(localized: HoldBack.beyondTheHelper.explanation) : nil
}
@@ -395,7 +398,7 @@ struct AppDetailView: View {
Button("Show in Finder") {
NSWorkspace.shared.activateFileViewerSelecting([plan.app.url])
}
- if PrivacyReset.isAllowed(bundleIdentifier: plan.app.bundleIdentifier) {
+ if PrivacyReset.isAllowed(bundleIdentifier: plan.app.bundleIdentifier), !plan.isAppInTheTrash {
Divider()
Button("Reset Privacy Permissions\u{2026}") { isConfirmingPrivacyReset = true }
.disabled(plan.isExcluded)
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index 9b085fb3..b8203cea 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -65,7 +65,7 @@ struct MultipleAppsView: View {
}
}
- if plan.apps.contains(where: { PrivacyReset.isAllowed(bundleIdentifier: $0.bundleIdentifier) }) {
+ if plan.apps.contains(where: { PrivacyReset.isAllowed(bundleIdentifier: $0.bundleIdentifier) && !plan.appsInTheTrash.contains($0.url) }) {
PrivacyResetRow(isOn: $resetsPrivacy, detail: PrivacyResetRow.beforeTheMove)
}
}
@@ -196,7 +196,7 @@ struct MultipleAppsView: View {
isLocked: item.requiresPrivileges && !helper.canAct,
isExcluded: item.isExcluded,
isLeftAlone: item.match?.heldBack?.cannotBeMoved == true || item.isBeyondTheHelper || (item.isApplication && item.isKeptByMacOS)
- || item.isPeels,
+ || item.isPeels || item.isInTheTrash,
appIdentifier: item.isApplication ? item.apps.first : nil,
isFirst: isFirst,
selection: plan, isSelected: plan.isSelected(item.url)
@@ -229,6 +229,9 @@ struct MultipleAppsView: View {
if item.isPeels {
lines.append(String(localized: "Left alone: Peel removes itself only from Settings."))
}
+ if item.isInTheTrash {
+ lines.append(String(localized: "Already in the Trash. What it left behind can still go."))
+ }
if item.isKeptByMacOS {
// Two literals, so the string catalog finds both.
lines.append(item.isApplication
@@ -242,7 +245,7 @@ struct MultipleAppsView: View {
private var removalNote: Text {
let urls = plan.question.request?.urls ?? []
let going = plan.apps.filter { urls.contains($0.url) }
- let staying = plan.apps.filter { !urls.contains($0.url) }
+ let staying = plan.apps.filter { !urls.contains($0.url) && !plan.appsInTheTrash.contains($0.url) }
var lines: [Text] = []
if !going.isEmpty {
lines.append(Text("Apps that go: \(list(going))"))