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 permissions kept Peel out of what it couldn't read

Țugui Dragoș43b0d5cb45eb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f66757ea..21a2475c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -204,6 +204,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
- A part inside an app says it comes with the app and that an update of the app may replace it.
- A plug-in installed in several formats says its format on each row.
- Nothing Needs Rosetta names the folders Peel read.
+- A job whose file Peel can't read and that macOS hasn't loaded is named as that, with a way to its page in Background
+ Items.
#### Homebrew
@@ -302,6 +304,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
search, and under File Search's count, so an entry left behind by an app you no longer use can be found.
- The divider between a list and its page stays where it is and can't be dragged: without the sidebar, the list takes
the room the sidebar covered.
+- A message about what couldn't be read says when the permissions of what it names kept Peel out, in the app and
+ from `peel`.
- The buttons at the foot of a page follow one rule in every language: two stand at the ends of the row, one is
centered, and those that act on the item itself stay together in the middle. Where a language's words leave no room
on one line, each takes a line of its own rather than having its title cut.
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index f72b621e..3751d056 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -80688,6 +80688,112 @@
}
}
},
+ "Its permissions don’t let your account read it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Jeho oprávnění neumožňují tomuto účtu ho přečíst."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Die Zugriffsrechte erlauben diesem Benutzeraccount nicht, es zu lesen."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sus permisos no dejan que esta cuenta lo lea."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ses permissions ne permettent pas à ce compte de le lire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "I suoi permessi non consentono a questo account di leggerlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "アクセス権により、このアカウントでは読み取れません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "사용 권한 때문에 이 계정으로 읽을 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De bevoegdheden ervan laten deze account het niet lezen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Jego uprawnienia nie pozwalają temu kontu go odczytać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "As permissões dele não deixam esta conta lê-lo."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Permisiunile sale nu îi permit contului dvs. să îl citească."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его права доступа не позволяют этой учетной записи его прочитать."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Behörigheterna låter inte det här kontot läsa den."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "İzinleri bu hesabın onu okumasına izin vermiyor."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його привілеї не дають цьому обліковому запису його прочитати."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其权限不允许此账户读取它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其權限不允許此帳號讀取它。"
+ }
+ }
+ }
+ },
"Its privacy permissions are reset too, and History can’t bring them back." : {
"localizations" : {
"cs" : {
@@ -132585,6 +132691,218 @@
}
}
},
+ "Peel couldn’t read %@, so it can’t tell whether what these jobs run needs Rosetta." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nemohl přečíst %@, takže nedokáže určit, jestli to, co tyto úlohy spouštějí, potřebuje prostředí Rosetta."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel konnte %@ nicht lesen und kann daher nicht sagen, ob das, was diese Jobs ausführen, Rosetta benötigt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ha podido leer %@, así que no puede saber si lo que ejecutan estas tareas necesita Rosetta."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’a pas pu lire %@ : il ne peut donc pas savoir si ce qu’exécutent ces tâches a besoin de Rosetta."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non è riuscito a leggere %@, quindi non può sapere se ciò che questi elementi eseguono richiede Rosetta."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelは%@を読み取れなかったため、これらのジョブが実行するものにRosettaが必要かどうかを判断できません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 %@을(를) 읽을 수 없었으므로 이 작업들이 실행하는 항목에 Rosetta가 필요한지 알 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kon %@ niet lezen en kan dus niet zeggen of wat deze taken uitvoeren Rosetta nodig heeft."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie mógł odczytać %@, więc nie wie, czy to, co uruchamiają te zadania, wymaga Rosetty."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não conseguiu ler %@, então não consegue saber se o que estas tarefas executam precisa do Rosetta."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu a putut citi %@, așa că nu poate spune dacă ce rulează aceste sarcini are nevoie de Rosetta."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не удалось прочитать %@, поэтому неизвестно, нужна ли Rosetta тому, что запускают эти задания."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kunde inte läsa %@, så det går inte att säga om det som jobben kör behöver Rosetta."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel şu dosyaları okuyamadı: %@. Bu yüzden bu işlerin çalıştırdığı şeylerin Rosetta gerektirip gerektirmediğini söyleyemiyor."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не вдалося прочитати %@, тож невідомо, чи потрібна Rosetta тому, що запускають ці завдання."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel未能读取%@,因此无法判断这些任务运行的内容是否需要Rosetta。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel無法讀取%@,因此無法判斷這些工作執行的內容是否需要Rosetta。"
+ }
+ }
+ }
+ },
+ "Peel couldn’t read %@, so it can’t tell whether what this job runs needs Rosetta." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nemohl přečíst %@, takže nedokáže určit, jestli to, co tato úloha spouští, potřebuje prostředí Rosetta."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel konnte %@ nicht lesen und kann daher nicht sagen, ob das, was dieser Job ausführt, Rosetta benötigt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ha podido leer %@, así que no puede saber si lo que ejecuta esta tarea necesita Rosetta."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’a pas pu lire %@ : il ne peut donc pas savoir si ce qu’exécute cette tâche a besoin de Rosetta."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non è riuscito a leggere %@, quindi non può sapere se ciò che questo elemento esegue richiede Rosetta."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelは%@を読み取れなかったため、このジョブが実行するものにRosettaが必要かどうかを判断できません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 %@을(를) 읽을 수 없었으므로 이 작업이 실행하는 항목에 Rosetta가 필요한지 알 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kon %@ niet lezen en kan dus niet zeggen of wat deze taak uitvoert Rosetta nodig heeft."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie mógł odczytać %@, więc nie wie, czy to, co uruchamia to zadanie, wymaga Rosetty."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não conseguiu ler %@, então não consegue saber se o que esta tarefa executa precisa do Rosetta."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu a putut citi %@, așa că nu poate spune dacă ce rulează această sarcină are nevoie de Rosetta."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не удалось прочитать %@, поэтому неизвестно, нужна ли Rosetta тому, что запускает это задание."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kunde inte läsa %@, så det går inte att säga om det som jobbet kör behöver Rosetta."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel şu dosyayı okuyamadı: %@. Bu yüzden bu işin çalıştırdığı şeyin Rosetta gerektirip gerektirmediğini söyleyemiyor."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не вдалося прочитати %@, тож невідомо, чи потрібна Rosetta тому, що запускає це завдання."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel未能读取%@,因此无法判断此任务运行的内容是否需要Rosetta。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel無法讀取%@,因此無法判斷此工作執行的內容是否需要Rosetta。"
+ }
+ }
+ }
+ },
"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" : {
@@ -197624,6 +197942,112 @@
}
}
},
+ "The permissions of some of them don’t let your account read them." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Oprávnění některých z nich neumožňují tomuto účtu je přečíst."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bei einigen davon erlauben die Zugriffsrechte diesem Benutzeraccount das Lesen nicht."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Los permisos de algunos de ellos no dejan que esta cuenta los lea."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Les permissions de certains d’entre eux ne permettent pas à ce compte de les lire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "I permessi di alcuni di essi non consentono a questo account di leggerli."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "一部の項目は、アクセス権により、このアカウントでは読み取れません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "일부 항목은 사용 권한 때문에 이 계정으로 읽을 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De bevoegdheden van sommige ervan laten deze account ze niet lezen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Uprawnienia niektórych z nich nie pozwalają temu kontu ich odczytać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "As permissões de alguns deles não deixam esta conta lê-los."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Permisiunile unora dintre ele nu îi permit contului dvs. să le citească."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Права доступа некоторых из них не позволяют этой учетной записи их прочитать."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Behörigheterna för några av dem låter inte det här kontot läsa dem."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bazılarının izinleri bu hesabın onları okumasına izin vermiyor."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Привілеї деяких із них не дають цьому обліковому запису їх прочитати."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其中一些项目的权限不允许此账户读取它们。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其中部分項目的權限不允許此帳號讀取它們。"
+ }
+ }
+ }
+ },
"The program it starts is gone, and no installed app claims it." : {
"localizations" : {
"cs" : {
@@ -200063,6 +200487,112 @@
}
}
},
+ "Their permissions don’t let your account read them." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Jejich oprávnění neumožňují tomuto účtu je přečíst."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Die Zugriffsrechte erlauben diesem Benutzeraccount nicht, sie zu lesen."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sus permisos no dejan que esta cuenta los lea."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Leurs permissions ne permettent pas à ce compte de les lire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "I loro permessi non consentono a questo account di leggerli."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "アクセス権により、このアカウントではこれらを読み取れません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "사용 권한 때문에 이 계정으로 이 항목들을 읽을 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De bevoegdheden ervan laten deze account ze niet lezen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ich uprawnienia nie pozwalają temu kontu ich odczytać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "As permissões deles não deixam esta conta lê-los."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Permisiunile lor nu îi permit contului dvs. să le citească."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Их права доступа не позволяют этой учетной записи их прочитать."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Behörigheterna låter inte det här kontot läsa dem."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "İzinleri bu hesabın onları okumasına izin vermiyor."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Їхні привілеї не дають цьому обліковому запису їх прочитати."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其权限不允许此账户读取它们。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其權限不允許此帳號讀取它們。"
+ }
+ }
+ }
+ },
"Their receipts go to the Trash, so macOS no longer counts these packages as installed. Nothing they put on this Mac is left, and History can put the receipts back.\n\n%@" : {
"comment" : "The message of the question before Forget All in Package Receipts. %@ is the list of the first packages, one per line.",
"localizations" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
index 08651f2e..e07ea653 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
@@ -176,9 +176,10 @@ struct OrphansCommand: AsyncParsableCommand {
guard !catalog.readEverything else { return nil }
let list = catalog.listOfFoldersUnreadable ? ["its list of app folders"] : []
let listed = Output.list(list + Output.named(catalog.unreadable))
+ let why = Output.whyNotRead(catalog.unreadable).map { " " + $0 } ?? ""
let access = catalog.needsFullDiskAccess ? " " + Output.fullDiskAccessAdvice : ""
let startOver = list.isEmpty ? "" : " Start the list over in Settings > General > App Folders."
- return CommandFailure("Peel couldn't read \(listed), so it can't tell which apps are installed. Nothing is listed, since the files of an app it can't see would look orphaned.\(access)\(startOver)")
+ return CommandFailure("Peel couldn't read \(listed), so it can't tell which apps are installed. Nothing is listed, since the files of an app it can't see would look orphaned.\(why)\(access)\(startOver)")
}
static func report(for scan: OrphanScan) -> Report {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index fab49340..f5969139 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -184,10 +184,22 @@ enum Output {
static let fullDiskAccessAdvice = "Give your terminal app Full Disk Access in System Settings to read the folders macOS protects."
- /// What a scan couldn't look into: the folders, and then Full Disk Access when it would open one of them.
+ /// What a scan couldn't look into: the folders, why when their permissions are why, and then Full Disk Access
+ /// when it would open one of them.
static func unreadableNote(for folders: [URL], needsFullDiskAccess: Bool) -> String {
let note = "Peel couldn't look inside \(list(named(folders))), so something may be there that isn't listed."
- return needsFullDiskAccess ? note + " " + fullDiskAccessAdvice : note
+ return [note, whyNotRead(folders), needsFullDiskAccess ? fullDiskAccessAdvice : nil]
+ .compactMap(\.self).joined(separator: " ")
+ }
+
+ /// The sentence that says the permissions kept Peel out of `items`, or nil when they didn't.
+ static func whyNotRead(_ items: [URL]) -> String? {
+ let closed = items.count(where: FileAccess.isClosedByItsPermissions)
+ if closed == 0 { return nil }
+ if closed < items.count { return "The permissions of some of them don't let your account read them." }
+ return closed == 1
+ ? "Its permissions don't let your account read it."
+ : "Their permissions don't let your account read them."
}
private static let mostNamedFolders = 4
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift b/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift
index 1a361b79..27e7f1f1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift
@@ -43,6 +43,8 @@ public struct IntelScan: Sendable {
public var unreadable: [URL] = []
/// True when macOS's privacy protection kept Peel out of one of them, which Full Disk Access lifts.
public var needsFullDiskAccess = false
+ /// The jobs whose files Peel can't read and that macOS hasn't loaded, so nothing says what each runs.
+ public var closedJobs: [BackgroundItem] = []
/// The kinds of launchd jobs `launchctl` didn't describe in a form Peel can read, whose programs it never saw.
public var unansweredJobs: Set<BackgroundItem.Kind> = []
@@ -235,11 +237,12 @@ public enum IntelInspector {
// A job or a command that runs what is listed already, or something inside it, is that code's, and a job is
// named on its row.
var listed = findings.map { PathPattern.comparablePath(of: $0.url) }
+ var closedJobs: [BackgroundItem] = []
unreadable += backgroundItems.unreadableFolders
for item in backgroundItems.items where !Task.isCancelled && !item.isExcluded {
// Peel can't tell what a job file it can't read runs, which may be Intel only.
- if item.isClosedToPeel, item.program == nil, let plist = item.plistURL {
- unreadable.append(plist)
+ if item.isClosedToPeel, item.program == nil, item.plistURL != nil {
+ closedJobs.append(item)
continue
}
guard let program = item.program.map({ URL(filePath: $0) }), !exclusions.excludes(program) else { continue }
@@ -297,6 +300,7 @@ public enum IntelInspector {
},
unreadable: unread,
needsFullDiskAccess: unread.contains { FullDiskAccess.canList($0) == .missing },
+ closedJobs: closedJobs,
unansweredJobs: backgroundItems.unanswered.kinds
)
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift b/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift
index f3766862..8b340df5 100644
--- a/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Support/FileAccess.swift
@@ -21,6 +21,21 @@ public enum FileAccess {
accessError == EPERM && !isLocked
}
+ /// How many of `items` their permissions keep this account from reading. A task of its own, since a disk that
+ /// stopped answering holds the question.
+ @concurrent public static func closedByPermissions(among items: [URL]) async -> Int {
+ items.count(where: isClosedByItsPermissions)
+ }
+
+ /// Whether the permissions keep this account from reading `url`: `access(2)` then fails with `EACCES`, while
+ /// macOS's privacy protection, which Full Disk Access lifts, fails with `EPERM`. A folder is read by going in too.
+ public static func isClosedByItsPermissions(_ url: URL) -> Bool {
+ let path = url.path(percentEncoded: false)
+ var info = stat()
+ let needed = stat(path, &info) == 0 && info.st_mode & S_IFMT == S_IFDIR ? R_OK | X_OK : R_OK
+ return access(path, needed) != 0 && errno == EACCES
+ }
+
/// Whether `url` is there and this process may not read it, as a file only its owner reads (`access(2)`).
static func isClosedToReading(_ url: URL) -> Bool {
access(url.path(percentEncoded: false), R_OK) != 0 && (errno == EACCES || errno == EPERM)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index 869b509e..33973c65 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -790,6 +790,33 @@ struct CommandLineTests {
)
}
+ @Test(.permissionsHold) func saysWhenPermissionsKeptItOutOfTheFolders() throws {
+ let directory = try TemporaryDirectory()
+ let closed = try directory.directory("Closed")
+ let alsoClosed = try directory.directory("AlsoClosed")
+ let open = try directory.directory("Open")
+ try directory.setPermissions(0o000, of: "Closed")
+ try directory.setPermissions(0o000, of: "AlsoClosed")
+ defer {
+ try? directory.setPermissions(0o755, of: "Closed")
+ try? directory.setPermissions(0o755, of: "AlsoClosed")
+ }
+
+ #expect(
+ Output.unreadableNote(for: [closed], needsFullDiskAccess: false)
+ .hasSuffix(" Its permissions don't let your account read it.")
+ )
+ #expect(
+ Output.unreadableNote(for: [closed, alsoClosed], needsFullDiskAccess: false)
+ .hasSuffix(" Their permissions don't let your account read them.")
+ )
+ #expect(
+ Output.unreadableNote(for: [closed, open], needsFullDiskAccess: false)
+ .hasSuffix(" The permissions of some of them don't let your account read them.")
+ )
+ #expect(!Output.unreadableNote(for: [open], needsFullDiskAccess: false).contains("permissions"))
+ }
+
@Test func namesTheFoldersItCouldNotReadAndWhenFullDiskAccessHelps() {
let locked = URL(filePath: "/Library/Application Support/Vendor")
let said = "Peel couldn't look inside /Library/Application Support/Vendor, so something may be there"
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileAccessTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileAccessTests.swift
index 1c2af050..56a96084 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileAccessTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileAccessTests.swift
@@ -18,6 +18,26 @@ struct FileAccessTests {
#expect(FileAccess.requiresPrivilegesToRemove(file))
}
+ @Test(.permissionsHold) func countsWhatItsPermissionsKeepThisAccountFromReading() async throws {
+ let directory = try TemporaryDirectory()
+ let closedFolder = try directory.directory("Closed")
+ let notSearchable = try directory.directory("NotSearchable")
+ let closedFile = try directory.file("closed.txt")
+ let open = try directory.directory("Open")
+ let openFile = try directory.file("open.txt")
+ try directory.setPermissions(0o000, of: "Closed")
+ try directory.setPermissions(0o400, of: "NotSearchable")
+ try directory.setPermissions(0o000, of: "closed.txt")
+ defer {
+ try? directory.setPermissions(0o755, of: "Closed")
+ try? directory.setPermissions(0o755, of: "NotSearchable")
+ }
+
+ #expect(await FileAccess.closedByPermissions(among: [closedFolder, notSearchable, closedFile]) == 3)
+ #expect(await FileAccess.closedByPermissions(among: [closedFolder, open, openFile]) == 1)
+ #expect(await FileAccess.closedByPermissions(among: [open, directory.url.appending(path: "gone")]) == 0)
+ }
+
/// macOS answers `EPERM` both for an item its privacy protection keeps from this process, as it keeps another
/// developer's app from a process without App Management, and for one that is locked. Only the first is a
/// permission the person can give.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift
index 70b37634..800cf115 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift
@@ -820,8 +820,7 @@ struct IntelInspectorTests {
measure: { _ in 1 }
)
- let named = scan.unreadable.map(PathPattern.comparablePath(of:)).sorted()
- let expected = [daemons.appending(path: "org.example.closed.plist"), agents]
- #expect(named == expected.map(PathPattern.comparablePath(of:)).sorted(), "what launchd can't load runs nothing")
+ #expect(scan.unreadable.map(PathPattern.comparablePath(of:)) == [PathPattern.comparablePath(of: agents)])
+ #expect(scan.closedJobs.map(\.label) == ["org.example.closed"], "what launchd can't load runs nothing")
}
}
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swift
index 24f2876f..d4b463b6 100644
--- a/Peel/Views/Cloud/CloudView.swift
+++ b/Peel/Views/Cloud/CloudView.swift
@@ -151,9 +151,7 @@ struct CloudView: View {
}
unreadableFoldersNote
if !cloud.notRead.isEmpty {
- Text(verbatim: UnreadableFoldersNotice.detail(
- naming: cloud.notRead.map(\.abbreviatedPath), needsFullDiskAccess: false
- ))
+ UnreadableFoldersDetail(folders: cloud.notRead)
}
sharedDownloadsNote
}
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index ab5908e5..aacb1daa 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -74,10 +74,9 @@ struct DuplicateList: View {
}
} description: {
if scan.needsFullDiskAccess || !scan.unreadableLocations.isEmpty {
- Text(verbatim: UnreadableFoldersNotice.detail(
- naming: scan.unreadableLocations.map(\.abbreviatedPath),
- needsFullDiskAccess: scan.needsFullDiskAccess
- ))
+ UnreadableFoldersDetail(
+ folders: scan.unreadableLocations, needsFullDiskAccess: scan.needsFullDiskAccess
+ )
}
if !scan.skippedLocations.isEmpty {
Text(verbatim: Self.reasons(scan.skippedLocations))
diff --git a/Peel/Views/Installers/InstallerList.swift b/Peel/Views/Installers/InstallerList.swift
index 98e82189..bde16e30 100644
--- a/Peel/Views/Installers/InstallerList.swift
+++ b/Peel/Views/Installers/InstallerList.swift
@@ -39,10 +39,7 @@ struct InstallerList: View {
ContentUnavailableView {
Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")
} description: {
- Text(verbatim: UnreadableFoldersNotice.detail(
- naming: installers.unreadable.map(\.abbreviatedPath),
- needsFullDiskAccess: true
- ))
+ UnreadableFoldersDetail(folders: installers.unreadable, needsFullDiskAccess: true)
} actions: {
UnreadableFoldersActions(folders: installers.unreadable, needsFullDiskAccess: true)
}
diff --git a/Peel/Views/Intel/IntelList.swift b/Peel/Views/Intel/IntelList.swift
index 894e4601..b40c2dc9 100644
--- a/Peel/Views/Intel/IntelList.swift
+++ b/Peel/Views/Intel/IntelList.swift
@@ -4,8 +4,11 @@ import SwiftUI
struct IntelList: View {
@Environment(IntelLibrary.self) private var intel
@Environment(AppLibrary.self) private var library
+ @Environment(BackgroundItemLibrary.self) private var backgroundItems
@State private var isRescanning = false
@State private var searchText = ""
+ /// How many of `unread` and of `closedJobFiles` their permissions keep this account from reading.
+ @State private var closed = (unread: 0, jobFiles: 0)
var body: some View {
@Bindable var intel = intel
@@ -99,6 +102,12 @@ struct IntelList: View {
}
}
}
+ .task(id: unread + closedJobFiles) {
+ closed = (
+ await FileAccess.closedByPermissions(among: unread),
+ await FileAccess.closedByPermissions(among: closedJobFiles)
+ )
+ }
// What the page lists can change from other pages and other apps, and a scan costs little, so once read it
// looks again, quietly, each time it is shown and each time Peel comes forward.
.task(id: library.revision) {
@@ -134,6 +143,10 @@ struct IntelList: View {
library.unreadable + (intel.scan?.unreadable ?? [])
}
+ private var closedJobFiles: [URL] {
+ intel.scan?.closedJobs.compactMap(\.plistURL) ?? []
+ }
+
private var needsFullDiskAccess: Bool {
library.unreadableNeedsFullDiskAccess || intel.scan?.needsFullDiskAccess == true
}
@@ -141,16 +154,26 @@ struct IntelList: View {
/// What Peel couldn't read, a paragraph for each kind, or nil when it read everything.
private var unreadParts: Text? {
let paths = unread.map(\.abbreviatedPath)
+ let jobFiles = closedJobFiles.map(\.abbreviatedPath)
let parts = (library.listOfFoldersUnreadable
? [Text("Peel can’t read its list of app folders, so it didn’t look at the apps in the folders you added.")] : [])
+ (paths.isEmpty
? [] : [Text("Peel couldn’t read \(RemovalFailureAlert.listedItems(paths)), so something there may need Rosetta.")])
+ + why(closed.unread, of: paths.count)
+ + (jobFiles.isEmpty ? [] : [jobFiles.count == 1
+ ? Text("Peel couldn’t read \(RemovalFailureAlert.listedItems(jobFiles)), so it can’t tell whether what this job runs needs Rosetta.")
+ : Text("Peel couldn’t read \(RemovalFailureAlert.listedItems(jobFiles)), so it can’t tell whether what these jobs run needs Rosetta.")])
+ + why(closed.jobFiles, of: jobFiles.count)
+ (needsFullDiskAccess ? [Text("Give Peel Full Disk Access so it can read the folders macOS protects.")] : [])
+ (intel.scan?.unansweredJobs.missingJobsNote.map { [Text($0)] } ?? [])
guard let first = parts.first else { return nil }
return parts.dropFirst().reduce(first) { Text("\($0)\n\n\($1)") }
}
+ private func why(_ closed: Int, of count: Int) -> [Text] {
+ UnreadableFoldersNotice.whyNotRead(closed: closed, of: count).map { [Text(verbatim: $0)] } ?? []
+ }
+
@ViewBuilder
private var unreadActions: some View {
if library.listOfFoldersUnreadable {
@@ -159,6 +182,12 @@ struct IntelList: View {
}
}
UnreadableFoldersActions(folders: unread, needsFullDiskAccess: needsFullDiskAccess)
+ if let job = intel.scan?.closedJobs.first {
+ Button("Review in Background Items") {
+ backgroundItems.selection = job.id
+ Navigator.shared.requestedTool = .backgroundItems
+ }
+ }
}
}
diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swift
index b2af5b1b..c5ec5420 100644
--- a/Peel/Views/Orphans/OrphanList.swift
+++ b/Peel/Views/Orphans/OrphanList.swift
@@ -48,11 +48,13 @@ struct OrphanList: View {
} description: {
let list = Text("Peel can’t read its list of app folders, so Orphaned Files lists nothing. Starting over keeps the old list beside a new one.")
let unread = Text("Peel couldn’t read \(RemovalFailureAlert.listedFolders(library.unreadable.map(\.abbreviatedPath))), 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.")
- let access = Text("Give Peel Full Disk Access so it can read the folders macOS protects.")
let parts = (library.listOfFoldersUnreadable ? [list] : [])
+ (library.unreadable.isEmpty ? [] : [unread])
- + (library.unreadableNeedsFullDiskAccess ? [access] : [])
- parts.dropFirst().reduce(parts.first ?? Text(verbatim: "")) { Text("\($0)\n\n\($1)") }
+ UnreadableFoldersDetail(
+ folders: library.unreadable,
+ needsFullDiskAccess: library.unreadableNeedsFullDiskAccess,
+ saying: parts.dropFirst().reduce(parts.first ?? Text(verbatim: "")) { Text("\($0)\n\n\($1)") }
+ )
} actions: {
if library.listOfFoldersUnreadable {
StartOverButton(file: library.foldersFile, startedOver: "Started the list of app folders over.") {
@@ -68,12 +70,11 @@ struct OrphanList: View {
ContentUnavailableView {
Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")
} description: {
- let named = Text("No orphaned files were found, but Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(unreadable.map(\.url.abbreviatedPath))), so there may be some there.")
- if orphans.scan?.needsFullDiskAccess == true {
- Text("\(named)\n\n\(Text("Give Peel Full Disk Access so it can read the folders macOS protects."))")
- } else {
- named
- }
+ UnreadableFoldersDetail(
+ folders: unreadable.map(\.url),
+ needsFullDiskAccess: orphans.scan?.needsFullDiskAccess == true,
+ saying: Text("No orphaned files were found, but Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(unreadable.map(\.url.abbreviatedPath))), so there may be some there.")
+ )
} actions: {
UnreadableFoldersActions(
folders: unreadable.map(\.url),
diff --git a/Peel/Views/Plugins/PluginList.swift b/Peel/Views/Plugins/PluginList.swift
index 1d172c80..50096ec0 100644
--- a/Peel/Views/Plugins/PluginList.swift
+++ b/Peel/Views/Plugins/PluginList.swift
@@ -64,12 +64,11 @@ struct PluginList: View {
ContentUnavailableView {
Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")
} description: {
- let named = Text("No plug-ins were found, but Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(plugins.unreadable.map(\.abbreviatedPath))), so there may be some there.")
- if plugins.needsFullDiskAccess {
- Text("\(named)\n\n\(Text("Give Peel Full Disk Access so it can read the folders macOS protects."))")
- } else {
- named
- }
+ UnreadableFoldersDetail(
+ folders: plugins.unreadable,
+ needsFullDiskAccess: plugins.needsFullDiskAccess,
+ saying: Text("No plug-ins were found, but Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(plugins.unreadable.map(\.abbreviatedPath))), so there may be some there.")
+ )
} actions: {
UnreadableFoldersActions(
folders: plugins.unreadable,
diff --git a/Peel/Views/Projects/ProjectList.swift b/Peel/Views/Projects/ProjectList.swift
index 6f2b55f0..49b5f49a 100644
--- a/Peel/Views/Projects/ProjectList.swift
+++ b/Peel/Views/Projects/ProjectList.swift
@@ -68,10 +68,9 @@ struct ProjectList: View {
ContentUnavailableView {
Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")
} description: {
- Text(verbatim: UnreadableFoldersNotice.detail(
- naming: projects.unreadable.map(\.abbreviatedPath),
- needsFullDiskAccess: projects.needsFullDiskAccess
- ))
+ UnreadableFoldersDetail(
+ folders: projects.unreadable, needsFullDiskAccess: projects.needsFullDiskAccess
+ )
unsearchableReasons
} actions: {
UnreadableFoldersActions(
diff --git a/Peel/Views/UnreadableFoldersNotice.swift b/Peel/Views/UnreadableFoldersNotice.swift
index 4f0cf9bb..8356c396 100644
--- a/Peel/Views/UnreadableFoldersNotice.swift
+++ b/Peel/Views/UnreadableFoldersNotice.swift
@@ -1,3 +1,4 @@
+import PeelCore
import SwiftUI
/// Over a list whose scan couldn't look into some folders: it names them, since something may be there that isn't
@@ -5,12 +6,15 @@ import SwiftUI
struct UnreadableFoldersNotice: View {
let folders: [URL]
var needsFullDiskAccess = false
+ @State private var closed = 0
var body: some View {
Notice(
title: Text("Some folders couldn’t be read"),
detail: Text(
- verbatim: Self.detail(naming: folders.map(\.abbreviatedPath), needsFullDiskAccess: needsFullDiskAccess)
+ verbatim: Self.detail(
+ naming: folders.map(\.abbreviatedPath), closed: closed, needsFullDiskAccess: needsFullDiskAccess
+ )
),
kind: needsFullDiskAccess ? .problem : .note
) {
@@ -18,21 +22,61 @@ struct UnreadableFoldersNotice: View {
}
.padding(.vertical, 6)
.listRowSeparator(.hidden)
+ .task(id: folders) { closed = await FileAccess.closedByPermissions(among: folders) }
}
/// The folders macOS lets a person allow one by one, apart from Full Disk Access.
private static let asksForItsFolderAlone = ["~/Desktop", "~/Documents", "~/Downloads"]
- /// The folders, the first few by path, and then the advice when Full Disk Access would open one of them.
- static func detail(naming paths: [String], needsFullDiskAccess: Bool) -> String {
+ /// The folders, the first few by path, why when their permissions are why, and then the advice when Full Disk
+ /// Access would open one of them.
+ static func detail(naming paths: [String], closed: Int, needsFullDiskAccess: Bool) -> String {
let named = paths.isEmpty
? [] : [String(localized: "Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(paths)), so something may be there that isn’t listed here.")]
+ let why = [whyNotRead(closed: closed, of: paths.count)].compactMap(\.self)
let advice = needsFullDiskAccess
? [String(localized: "Give Peel Full Disk Access so it can read the folders macOS protects.")] : []
let foldersAlone = !paths.filter(asksForItsFolderAlone.contains).isEmpty && needsFullDiskAccess
? [String(localized: "For Desktop, Documents, or Downloads alone, allow Peel in System Settings > Privacy & Security > Files & Folders.")]
: []
- return (named + advice + foldersAlone).joined(separator: "\n\n")
+ return (named + why + advice + foldersAlone).joined(separator: "\n\n")
+ }
+
+ /// The sentence that says the permissions kept Peel out, given how many of how many items they closed.
+ static func whyNotRead(closed: Int, of count: Int) -> String? {
+ if closed == 0 { return nil }
+ if closed < count { return String(localized: "The permissions of some of them don’t let your account read them.") }
+ return closed == 1
+ ? String(localized: "Its permissions don’t let your account read it.")
+ : String(localized: "Their permissions don’t let your account read them.")
+ }
+}
+
+/// What Peel couldn't read, said under a page's own message, with why when the permissions of `folders` are why.
+struct UnreadableFoldersDetail: View {
+ let folders: [URL]
+ var needsFullDiskAccess = false
+ /// The page's own sentence naming them, in place of the shared one.
+ var saying: Text?
+ @State private var closed = 0
+
+ private var text: Text {
+ guard let saying else {
+ return Text(
+ verbatim: UnreadableFoldersNotice.detail(
+ naming: folders.map(\.abbreviatedPath), closed: closed, needsFullDiskAccess: needsFullDiskAccess
+ )
+ )
+ }
+ let why = UnreadableFoldersNotice.whyNotRead(closed: closed, of: folders.count).map { Text(verbatim: $0) }
+ let advice = needsFullDiskAccess
+ ? Text("Give Peel Full Disk Access so it can read the folders macOS protects.") : nil
+ return [why, advice].compactMap(\.self).reduce(saying) { Text("\($0)\n\n\($1)") }
+ }
+
+ var body: some View {
+ text
+ .task(id: folders) { closed = await FileAccess.closedByPermissions(among: folders) }
}
}
diff --git a/PeelTests/UnreadableFoldersTests.swift b/PeelTests/UnreadableFoldersTests.swift
index d7746e3d..8847dab3 100644
--- a/PeelTests/UnreadableFoldersTests.swift
+++ b/PeelTests/UnreadableFoldersTests.swift
@@ -14,16 +14,26 @@ struct UnreadableFoldersTests {
@Test func namesTheFoldersAndAddsTheAdviceOnlyWhenFullDiskAccessWouldHelp() {
let paths = ["/Users/me/Documents/app", "/Users/me/work/pgdata"]
- let advice = UnreadableFoldersNotice.detail(naming: [], needsFullDiskAccess: true)
+ let advice = UnreadableFoldersNotice.detail(naming: [], closed: 0, needsFullDiskAccess: true)
- let both = UnreadableFoldersNotice.detail(naming: paths, needsFullDiskAccess: true)
- let named = UnreadableFoldersNotice.detail(naming: paths, needsFullDiskAccess: false)
+ let both = UnreadableFoldersNotice.detail(naming: paths, closed: 0, needsFullDiskAccess: true)
+ let named = UnreadableFoldersNotice.detail(naming: paths, closed: 0, needsFullDiskAccess: false)
#expect(!advice.isEmpty)
#expect(both.contains("pgdata") && both.hasSuffix(advice))
#expect(named.contains("pgdata") && !named.contains(advice))
}
+ @Test func saysThePermissionsKeptPeelOutOnlyWhenTheyDid() throws {
+ let all = try #require(UnreadableFoldersNotice.whyNotRead(closed: 2, of: 2))
+ let some = try #require(UnreadableFoldersNotice.whyNotRead(closed: 1, of: 2))
+ let one = try #require(UnreadableFoldersNotice.whyNotRead(closed: 1, of: 1))
+
+ #expect(UnreadableFoldersNotice.whyNotRead(closed: 0, of: 2) == nil)
+ #expect(Set([all, some, one]).count == 3)
+ #expect(UnreadableFoldersNotice.detail(naming: ["/a", "/b"], closed: 1, needsFullDiskAccess: false).hasSuffix(some))
+ }
+
@Test func anAlertsFirstItemsAndHowManyMore() {
let (shown, more) = RemovalFailureAlert.first(Array(1...60))