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 when an app another page asked for can't be shown

Țugui Dragoș00b08ef9bea8
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index ed2cc1e7..1c30a5dc 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -6464,6 +6464,112 @@
}
}
},
+ "%@ isn’t there anymore, or macOS doesn’t let this account read it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Položka %@ už tam není, nebo ji systém macOS tomuto účtu nedovoluje přečíst."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ ist nicht mehr vorhanden, oder macOS erlaubt diesem Benutzeraccount nicht, es zu lesen."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ ya no está ahí, o macOS no deja que esta cuenta lo lea."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ n’est plus là, ou macOS ne permet pas à ce compte de le lire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ non c’è più, oppure macOS non ne consente la lettura a questo account."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@はもうそこにないか、macOSがこのアカウントに読み取りを許可していません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@이(가) 더 이상 그곳에 없거나, macOS가 이 계정에서 읽지 못하게 합니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ is er niet meer, of macOS laat deze account het niet lezen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aplikacji %@ już tam nie ma albo macOS nie pozwala temu kontu jej odczytać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ não está mais lá, ou o macOS não permite que esta conta o leia."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ nu mai este acolo sau macOS nu îi permite acestui cont să îl citească."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Объекта %@ больше нет, или macOS не позволяет этой учетной записи его прочитать."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ finns inte längre, eller så låter macOS inte det här kontot läsa den."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ artık orada değil veya macOS bu hesabın onu okumasına izin vermiyor."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ там уже немає, або macOS не дає цьому обліковому запису це прочитати."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@已不存在,或者macOS不允许此账户读取它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@已不在那裡,或macOS不允許此帳號讀取它。"
+ }
+ }
+ }
+ },
"%@ of %@" : {
"localizations" : {
"cs" : {
@@ -132055,6 +132161,112 @@
}
}
},
+ "Peel couldn’t open this app" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel tuto aplikaci nemohl otevřít"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel konnte diese App nicht öffnen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ha podido abrir esta app"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’a pas pu ouvrir cette app"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non è riuscito ad aprire questa app"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelはこのアプリを開けませんでした"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 이 앱을 열 수 없음"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kon deze app niet openen"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie mógł otworzyć tej aplikacji"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não conseguiu abrir este app"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu a putut deschide această aplicație"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не удалось открыть это приложение"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kunde inte öppna den här appen"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel bu uygulamayı açamadı"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не вдалося відкрити цю програму"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel未能打开此App"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel無法打開此App"
+ }
+ }
+ }
+ },
"Peel couldn’t read %@, so it can’t tell which apps are installed. Nothing is listed here, since the files of an app it can’t see would look orphaned." : {
"localizations" : {
"cs" : {
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index 69abf909..fe57e1de 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -143,6 +143,8 @@ final class AppLibrary {
private(set) var homebrewApps: [InstalledApp.ID: HomebrewPackage] = [:]
/// The rows chosen in the list, which the page beside it shows.
var selection: Set<InstalledApp.ID> = []
+ /// An app something asked to show that Peel couldn't read, which the window says.
+ var couldNotShow: URL?
/// The apps selected with their checkboxes, to be removed together. Kept apart from `selection`, so
/// choosing a row to look at never clears the batch.
var picked: Set<InstalledApp.ID> = []
@@ -1050,6 +1052,10 @@ final class AppLibrary {
return true
}
+ func showRequested(_ app: URL) async {
+ if await !reveal([app]) { couldNotShow = app }
+ }
+
private func listed(_ url: URL) async -> InstalledApp.ID? {
let bundleURL = url.standardizedFileURL
// Looked up on disk, since a trailing slash, another case, or a link can name a bundle already listed.
diff --git a/Peel/Views/ContentView.swift b/Peel/Views/ContentView.swift
index 9106565e..215bd509 100644
--- a/Peel/Views/ContentView.swift
+++ b/Peel/Views/ContentView.swift
@@ -160,6 +160,15 @@ struct ContentView: View {
.task(id: library.hasLoaded) {
applyPendingRequest()
}
+ .alert(
+ Text("Peel couldn’t open this app"),
+ isPresented: Binding(get: { library.couldNotShow != nil }, set: { if !$0 { library.couldNotShow = nil } }),
+ presenting: library.couldNotShow
+ ) { _ in
+ Button("OK", role: .cancel) {}
+ } message: { app in
+ Text("\(app.abbreviatedPath) isn’t there anymore, or macOS doesn’t let this account read it.")
+ }
// The window's Undo, so Command-Z after a removal means what it means everywhere else on a Mac.
.focusedSceneValue(\.removalHistory, history)
.onAppear { history.canUseHelper = helper.canAct }
@@ -174,7 +183,7 @@ struct ContentView: View {
.onChange(of: navigator.requestedApp) { _, app in
guard let app, library.hasLoaded else { return }
navigator.requestedApp = nil
- Task { await library.reveal([app]) }
+ Task { await library.showRequested(app) }
}
}
@@ -388,7 +397,7 @@ struct ContentView: View {
}
if let app = navigator.requestedApp, library.hasLoaded {
navigator.requestedApp = nil
- Task { await library.reveal([app]) }
+ Task { await library.showRequested(app) }
}
}
diff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swift
index 80248ebb..93449338 100644
--- a/PeelTests/AppLibraryTests.swift
+++ b/PeelTests/AppLibraryTests.swift
@@ -259,6 +259,24 @@ private nonisolated final class TestClock: Sendable {
Data(#"{"resultCount":1,"results":[{"kind":"mac-software","version":"\#(version)"}]}"#.utf8)
}
+ @Test func saysWhenAnAppSomethingAskedForCanNotBeShown() async throws {
+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
+ let bundle = try soldApp(in: folder)
+ defer { try? FileManager.default.removeItem(at: folder) }
+ let made = try MadeUpDefaults()
+ defer { made.forget() }
+ let library = library(with: made.defaults, notesIn: folder)
+ let gone = folder.appending(path: "Gone.app", directoryHint: .isDirectory)
+
+ await library.showRequested(bundle)
+ #expect(library.couldNotShow == nil)
+ #expect(library.selection.count == 1)
+
+ await library.showRequested(gone)
+ #expect(library.couldNotShow == gone)
+ #expect(library.selection.count == 1)
+ }
+
@Test func anOlderAppStoreAnswerLeavesTheUpdateItFound() async throws {
let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
let bundle = try soldApp(in: folder)