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
Say that only an administrator can remove Peel from this account
Țugui Dragoș527501227fc6
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 7c2d6d65..bab4bfd3 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -105243,6 +105243,112 @@}}},+ "Only an administrator can remove Peel’s helper, so Peel can’t remove itself from this account. Log in as an administrator and choose Remove Peel there." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Pomocníka Peelu může odstranit jen správce, takže Peel se z tohoto účtu odstranit nemůže. Přihlaste se jako správce a tam zvolte „Odstranit Peel“."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nur ein Administrator kann das Hilfsprogramm von Peel entfernen, daher kann sich Peel mit diesem Benutzeraccount nicht selbst entfernen. Melde dich als Administrator an und wähle dort „Peel entfernen“."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo un administrador puede eliminar el asistente de Peel, así que Peel no puede eliminarse desde esta cuenta. Inicia sesión como administrador y elige “Eliminar Peel” allí."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seul un administrateur peut supprimer l’utilitaire de Peel : Peel ne peut donc pas se supprimer depuis ce compte. Ouvrez une session en tant qu’administrateur et choisissez « Supprimer Peel » dans cette session."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo un amministratore può rimuovere l’assistente di Peel, quindi Peel non può rimuovere sé stesso da questo account. Esegui il login come amministratore e scegli “Rimuovi Peel” da lì."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelのヘルパーを取り除けるのは管理者だけのため、Peelはこのアカウントから自身をアンインストールできません。管理者としてログインし、そこで“Peelをアンインストール”を選択してください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "관리자만 Peel 보조 프로그램을 제거할 수 있으므로, 이 계정에서는 Peel이 자신을 제거할 수 없습니다. 관리자로 로그인한 다음 그곳에서 ‘Peel 제거’를 선택하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Alleen een beheerder kan het hulpprogramma van Peel verwijderen, dus Peel kan zichzelf niet verwijderen vanuit deze account. Log in als beheerder en kies daar 'Verwijder Peel'."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tylko administrator może odinstalować pomocnika Peel, więc Peel nie może odinstalować się z tego konta. Zaloguj się jako administrator i tam wybierz „Odinstaluj Peel”."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Só um administrador pode remover o auxiliar do Peel, então o Peel não pode se remover a partir desta conta. Inicie sessão como administrador e escolha “Remover o Peel” lá."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Doar un administrator poate elimina instrumentul de ajutor Peel, așa că Peel nu se poate elimina din acest cont. Faceți login ca administrator și alegeți „Eliminați Peel” de acolo."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Удалить помощника Peel может только администратор, поэтому из этой учетной записи Peel не может удалить себя. Войдите как администратор и выберите там «Удалить Peel»."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bara en administratör kan ta bort Peels hjälpprogram, så Peel kan inte ta bort sig själv från det här kontot. Logga in som administratör och välj ”Ta bort Peel” där."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel’in yardımcısını yalnızca bir yönetici kaldırabilir, bu yüzden Peel kendini bu hesaptan kaldıramaz. Yönetici olarak oturum açın ve orada “Peel’i Kaldır” düğmesini tıklayın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Вилучити помічника Peel може лише адміністратор, тож із цього облікового запису Peel не може вилучити себе. Увійдіть як адміністратор і виберіть там «Вилучити Peel»."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有管理员才能移除Peel的帮助程序,因此Peel无法在此账户中移除自己。请以管理员身份登录,然后在那里选取“移除Peel”。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有管理者能移除Peel的輔助程式,因此Peel無法從此帳號移除自己。請以管理者身分登入,並在那裡選擇「移除Peel」。"+ }+ }+ }+ },"Only an administrator can remove these" : {"localizations" : {"cs" : {diff --git a/Peel/Model/SelfUninstall.swift b/Peel/Model/SelfUninstall.swiftindex f0415d90..c5e477ce 100644--- a/Peel/Model/SelfUninstall.swift+++ b/Peel/Model/SelfUninstall.swift@@ -69,6 +69,16 @@ final class SelfUninstall {return homebrewKnowsItsApps ? .removePeel : .waitingForHomebrew}+ /// Whether Peel can't remove itself from this account: its helper is registered, and only an administrator may+ /// change it.+ static func waitsForAnAdministrator(standing: PrivilegedHelper.Standing, status: PrivilegedHelper.Status) -> Bool {+ standing == .notThisAccount && (status == .enabled || status == .requiresApproval)+ }++ static var onlyAnAdministrator: String {+ String(localized: "Only an administrator can remove Peel’s helper, so Peel can’t remove itself from this account. Log in as an administrator and choose Remove Peel there.")+ }+static var removeCommand: String {"sudo rm -f /usr/local/bin/peel"}@@ -169,7 +179,7 @@ final class SelfUninstall {let helperStayed = String(localized: "The helper couldn’t be removed, so Peel stayed where it was.")switch stay {case .helperIsNotThisAccounts:- return helperStayed+ return onlyAnAdministratorcase .helperStayed(let reason, let ledger):let reason = reason ?? helperStayedreturn ledger == .moved ? "\(reason)\n\n\(ledgerInTheTrash)" : reasondiff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex 6b690786..430724db 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -421,7 +421,7 @@ private struct GeneralSettingsView: View {// Peel's alone..disabled(selfUninstall.isRunning || !library.hasLoaded || way == .waitingForHomebrew- || !history.mayMove || Self.runsFromAReadOnlyCopy+ || !history.mayMove || Self.runsFromAReadOnlyCopy || waitsForAnAdministrator)}if selfUninstall.isRunning {@@ -448,6 +448,10 @@ private struct GeneralSettingsView: View {Text(SelfUninstall.explanation(of: .readOnlyCopy)).font(.callout).foregroundStyle(.secondary)+ } else if waitsForAnAdministrator {+ Text(verbatim: SelfUninstall.onlyAnAdministrator)+ .font(.callout)+ .foregroundStyle(.secondary)} else if way == .waitingForHomebrew {Text("Peel waits for Homebrew to say whether it installed this copy, since a copy Homebrew installed is removed with Homebrew.").font(.callout)@@ -624,6 +628,10 @@ extension GeneralSettingsView {}+ private var waitsForAnAdministrator: Bool {+ SelfUninstall.waitsForAnAdministrator(standing: helper.standing, status: helper.status)+ }+/// The cask Homebrew installed this copy of Peel from, found by the rule the Applications list follows.fileprivate var ownCask: HomebrewPackage? {guard let app = library.apps.first(where: \.isTheRunningCopy) else { return nil }diff --git a/PeelTests/SelfUninstallTests.swift b/PeelTests/SelfUninstallTests.swiftindex c71881f3..9486ef4c 100644--- a/PeelTests/SelfUninstallTests.swift+++ b/PeelTests/SelfUninstallTests.swift@@ -42,3 +42,13 @@ struct SelfUninstallTests {#expect(told.withLock { $0.count } == 1)}}++@MainActor+struct SelfUninstallAccountTests {+ @Test func waitsForAnAdministratorOnlyWhileTheHelperIsRegistered() {+ #expect(SelfUninstall.waitsForAnAdministrator(standing: .notThisAccount, status: .enabled))+ #expect(SelfUninstall.waitsForAnAdministrator(standing: .notThisAccount, status: .requiresApproval))+ #expect(!SelfUninstall.waitsForAnAdministrator(standing: .notThisAccount, status: .notRegistered))+ #expect(!SelfUninstall.waitsForAnAdministrator(standing: .ready, status: .enabled))+ }+}