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
Offer no helper install to a copy that did not register it
Țugui Dragoșca4486a34953
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 92ecb7e5..91b221e6 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -133740,108 +133740,109 @@}}},- "Peel’s helper was installed by another copy of Peel, and this copy can’t use it." : {+ "Peel’s helper was installed by another copy of Peel, and this copy can’t use it. Open the copy of Peel that installed it." : {+ "comment" : "Shown in Settings > Helper and over pages that need the helper, when a copy of Peel in another folder installed it. That copy is the one to open; this one offers no Install.","localizations" : {"cs" : {"stringUnit" : {"state" : "translated",- "value" : "Pomocníka Peelu nainstalovala jiná kopie Peelu a tato kopie ho nemůže používat."+ "value" : "Pomocníka Peelu nainstalovala jiná kopie Peelu a tato kopie ho nemůže používat. Otevřete tu kopii Peelu, která ho nainstalovala."}},"de" : {"stringUnit" : {"state" : "translated",- "value" : "Das Hilfsprogramm von Peel wurde von einer anderen Peel-Kopie installiert, und diese Kopie kann es nicht verwenden."+ "value" : "Das Hilfsprogramm von Peel wurde von einer anderen Peel-Kopie installiert, und diese Kopie kann es nicht verwenden. Öffne die Peel-Kopie, die es installiert hat."}},"es" : {"stringUnit" : {"state" : "translated",- "value" : "El asistente de Peel lo instaló otra copia de Peel, y esta copia no puede usarlo."+ "value" : "El asistente de Peel lo instaló otra copia de Peel, y esta copia no puede usarlo. Abre la copia de Peel que lo instaló."}},"fr" : {"stringUnit" : {"state" : "translated",- "value" : "L’utilitaire de Peel a été installé par une autre copie de Peel, et cette copie ne peut pas l’utiliser."+ "value" : "L’utilitaire de Peel a été installé par une autre copie de Peel, et cette copie ne peut pas l’utiliser. Ouvrez la copie de Peel qui l’a installé."}},"it" : {"stringUnit" : {"state" : "translated",- "value" : "L’assistente di Peel è stato installato da un’altra copia di Peel, e questa copia non può usarlo."+ "value" : "L’assistente di Peel è stato installato da un’altra copia di Peel, e questa copia non può usarlo. Apri la copia di Peel che l’ha installato."}},"ja" : {"stringUnit" : {"state" : "translated",- "value" : "Peelのヘルパーは、Peelの別のコピーによってインストールされたため、このコピーでは使用できません。"+ "value" : "Peelのヘルパーは、Peelの別のコピーによってインストールされたため、このコピーでは使用できません。ヘルパーをインストールしたPeelのコピーを開いてください。"}},"ko" : {"stringUnit" : {"state" : "translated",- "value" : "다른 Peel 복사본이 Peel 보조 프로그램을 설치했으므로 이 복사본에서는 사용할 수 없습니다."+ "value" : "다른 Peel 복사본이 Peel 보조 프로그램을 설치했으므로 이 복사본에서는 사용할 수 없습니다. 보조 프로그램을 설치한 Peel 복사본을 여십시오."}},"nl" : {"stringUnit" : {"state" : "translated",- "value" : "Het hulpprogramma van Peel is geïnstalleerd door een andere kopie van Peel, en deze kopie kan het niet gebruiken."+ "value" : "Het hulpprogramma van Peel is geïnstalleerd door een andere kopie van Peel, en deze kopie kan het niet gebruiken. Open de kopie van Peel die het heeft geïnstalleerd."}},"pl" : {"stringUnit" : {"state" : "translated",- "value" : "Pomocnik Peel został zainstalowany przez inną kopię Peel i ta kopia nie może z niego korzystać."+ "value" : "Pomocnik Peel został zainstalowany przez inną kopię Peel i ta kopia nie może z niego korzystać. Otwórz kopię Peel, która go zainstalowała."}},"pt" : {"stringUnit" : {"state" : "translated",- "value" : "O auxiliar do Peel foi instalado por outra cópia do Peel, e esta cópia não pode usá-lo."+ "value" : "O auxiliar do Peel foi instalado por outra cópia do Peel, e esta cópia não pode usá-lo. Abra a cópia do Peel que o instalou."}},"ro" : {"stringUnit" : {"state" : "translated",- "value" : "Instrumentul de ajutor Peel a fost instalat de o altă copie Peel, iar această copie nu îl poate folosi."+ "value" : "Instrumentul de ajutor Peel a fost instalat de o altă copie Peel, iar această copie nu îl poate folosi. Deschideți copia Peel care l‑a instalat."}},"ru" : {"stringUnit" : {"state" : "translated",- "value" : "Помощник Peel установлен другой копией Peel, и эта копия не может им пользоваться."+ "value" : "Помощник Peel установлен другой копией Peel, и эта копия не может им пользоваться. Откройте копию Peel, которая его установила."}},"sv" : {"stringUnit" : {"state" : "translated",- "value" : "Peels hjälpprogram installerades av en annan kopia av Peel, och den här kopian kan inte använda det."+ "value" : "Peels hjälpprogram installerades av en annan kopia av Peel, och den här kopian kan inte använda det. Öppna den kopia av Peel som installerade det."}},"tr" : {"stringUnit" : {"state" : "translated",- "value" : "Peel’in yardımcısını Peel’in başka bir kopyası yükledi ve bu kopya onu kullanamaz."+ "value" : "Peel’in yardımcısını Peel’in başka bir kopyası yükledi ve bu kopya onu kullanamaz. Yardımcıyı yükleyen Peel kopyasını açın."}},"uk" : {"stringUnit" : {"state" : "translated",- "value" : "Помічника Peel інстальовано іншою копією Peel, і ця копія не може ним користуватися."+ "value" : "Помічника Peel інстальовано іншою копією Peel, і ця копія не може ним користуватися. Відкрийте копію Peel, яка його інсталювала."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "Peel的帮助程序由另一个Peel副本安装,当前副本无法使用它。"+ "value" : "Peel的帮助程序由另一个Peel副本安装,当前副本无法使用它。请打开安装它的那个Peel副本。"}},"zh-Hant" : {"stringUnit" : {"state" : "translated",- "value" : "Peel的輔助程式是由另一份Peel副本安裝的,此副本無法使用它。"+ "value" : "Peel的輔助程式是由另一份Peel副本安裝的,此副本無法使用它。請打開安裝它的那份Peel副本。"}}}diff --git a/Peel/Model/HelperModel.swift b/Peel/Model/HelperModel.swiftindex f16fe55d..eea92a6c 100644--- a/Peel/Model/HelperModel.swift+++ b/Peel/Model/HelperModel.swift@@ -62,7 +62,7 @@ final class HelperModel {/// `SMAppService.h`, registering a service that is already registered, or not approved by the user,/// throws an error. Neither is reported as a failure, since the status says what happened.func install() async -> Failure? {- guard !isChanging else { return nil }+ guard !isChanging, !isRegisteredByAnotherCopy else { return nil }let (wasAllowed, error) = await change(.install) { try await PrivilegedHelper.register() }if wasAllowed, status == .requiresApproval {PrivilegedHelper.openLoginItemsSettings()diff --git a/Peel/Views/HelperRequiredBanner.swift b/Peel/Views/HelperRequiredBanner.swiftindex 9e7be692..e453df1e 100644--- a/Peel/Views/HelperRequiredBanner.swift+++ b/Peel/Views/HelperRequiredBanner.swift@@ -29,12 +29,18 @@ struct HelperRequiredBanner: View {}extension PrivilegedHelper.Standing {+ /// Never while another copy's registration stands: every copy shares one helper label and one background item+ /// record, and a second registration from another bundle is what keeps the helper from starting.+ func offersInstall(registeredByAnotherCopy: Bool) -> Bool {+ self == .notInstalled && !registeredByAnotherCopy+ }+/// Why Peel's helper can't act, for a page or a control that needs it.func whyItCannotAct(registeredByAnotherCopy: Bool) -> LocalizedStringResource {switch self {case .ready, .notInstalled:registeredByAnotherCopy- ? "Peel’s helper was installed by another copy of Peel, and this copy can’t use it."+ ? "Peel’s helper was installed by another copy of Peel, and this copy can’t use it. Open the copy of Peel that installed it.": "Install Peel’s helper to remove the items in the system folders it serves."case .waitingForApproval: "Peel’s helper is waiting to be allowed in System Settings, under Login Items & Extensions."case .notThisAccount: "Only an administrator can use Peel’s helper, so Peel can’t remove these from this account."diff --git a/Peel/Views/Home/HomePermissionsView.swift b/Peel/Views/Home/HomePermissionsView.swiftindex 34d4c31c..63faad8b 100644--- a/Peel/Views/Home/HomePermissionsView.swift+++ b/Peel/Views/Home/HomePermissionsView.swift@@ -386,7 +386,10 @@ fileprivate extension HomeModel {switch state {case .on, .notThisAccount, .checking: return nilcase .pending: return "Open System Settings"- case .missing, .off: return helper.standing == .notAnswering ? "Repair" : "Install"+ case .missing, .off:+ if helper.standing == .notAnswering { return "Repair" }+ return helper.standing.offersInstall(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy)+ ? "Install" : nil}case .appManagement: return state == .on ? nil : "Open System Settings"// The optional rows open System Settings from their name, so they need no button. Notifications hasdiff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex 3b7f590c..dfd1a448 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -674,15 +674,16 @@ private struct HelperSettingsView: View {Section {switch helper.standing {case .notInstalled:- if helper.isRegisteredByAnotherCopy {- Text("Peel’s helper was installed by another copy of Peel, and this copy can’t use it.")+ if helper.standing.offersInstall(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy) {+ Button("Install Helper", systemImage: "lock.shield") {+ Task { failure = await helper.install() }+ }+ .disabled(helper.isChanging)+ .centeredInRow()+ } else {+ Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: true)).font(.callout)}- Button("Install Helper", systemImage: "lock.shield") {- Task { failure = await helper.install() }- }- .disabled(helper.isChanging)- .centeredInRow()case .waitingForApproval:Text("Allow Peel in System Settings under Login Items & Extensions.").font(.callout)diff --git a/PeelTests/HelperReasonTests.swift b/PeelTests/HelperReasonTests.swiftindex fafe5f1a..8c971864 100644--- a/PeelTests/HelperReasonTests.swift+++ b/PeelTests/HelperReasonTests.swift@@ -12,8 +12,14 @@ struct HelperReasonTests {#expect(reason(.notThisAccount, false) == String(localized: "Only an administrator can use Peel’s helper, so Peel can’t remove these from this account."))#expect(reason(.notInstalled, false) == String(localized: "Install Peel’s helper to remove the items in the system folders it serves."))- #expect(reason(.notInstalled, true) == String(localized: "Peel’s helper was installed by another copy of Peel, and this copy can’t use it."))+ #expect(reason(.notInstalled, true) == String(localized: "Peel’s helper was installed by another copy of Peel, and this copy can’t use it. Open the copy of Peel that installed it."))#expect(reason(.waitingForApproval, false) == String(localized: "Peel’s helper is waiting to be allowed in System Settings, under Login Items & Extensions."))#expect(reason(.notAnswering, false) == String(localized: "Peel’s helper isn’t answering. Repair it in Settings."))}++ @Test func offersNoInstallToACopyThatDidNotRegisterIt() {+ #expect(PrivilegedHelper.Standing.notInstalled.offersInstall(registeredByAnotherCopy: false))+ #expect(!PrivilegedHelper.Standing.notInstalled.offersInstall(registeredByAnotherCopy: true))+ #expect(!PrivilegedHelper.Standing.ready.offersInstall(registeredByAnotherCopy: false))+ }}