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.

Peel shows the job and settings files macOS can't load

Țugui Dragoș14cbf6fd2fa8
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index bc8850f1..70a6386d 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -16976,6 +16976,112 @@
}
}
},
+ "Can’t be read as a property list, so nothing can read these settings." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nelze ho přečíst jako seznam vlastností, takže tato nastavení nedokáže přečíst nic."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kann nicht als Eigenschaftsliste gelesen werden, daher kann nichts diese Einstellungen lesen."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se puede leer como lista de propiedades, así que nada puede leer estos ajustes."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ce fichier ne peut pas être lu comme une liste de propriétés : rien ne peut donc lire ces réglages."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non si può leggere come property list, quindi nessun programma può leggere queste impostazioni."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "プロパティリストとして読み取れないため、この設定を読み取れるものはありません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "속성 목록으로 읽을 수 없으므로 어떤 프로그램도 이 설정을 읽을 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kan niet als eigenschappenlijst worden gelezen, dus niets kan deze instellingen lezen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Tego pliku nie można odczytać jako listy właściwości, więc nic nie odczyta tych ustawień."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não pode ser lido como lista de propriedades, por isso nada consegue ler estes ajustes."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nu poate fi citit ca listă de proprietăți, deci nimic nu poate citi aceste configurări."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не удается прочитать как список свойств, поэтому эти настройки не может прочитать ни одна программа."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kan inte läsas som en egenskapslista, så ingenting kan läsa de här inställningarna."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Özellik listesi olarak okunamıyor, bu yüzden bu ayarları hiçbir şey okuyamaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Файл не вдається прочитати як список властивостей, тож ці налаштування ніщо не може прочитати."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "无法作为属性列表读取,因此任何程序都无法读取这些设置。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "無法讀取為屬性列表,因此沒有任何程式能讀取這些設定。"
+ }
+ }
+ }
+ },
"Can’t check for updates" : {
"localizations" : {
"cs" : {
@@ -47311,6 +47417,112 @@
}
}
},
+ "It can’t be read as a property list, or it names no job, so macOS never loads it and nothing runs from it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nelze ho přečíst jako seznam vlastností, nebo neuvádí žádnou úlohu, takže ho systém macOS nikdy nenačte a nic se z něj nespouští."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Diese Datei kann nicht als Eigenschaftsliste gelesen werden oder nennt keinen Job, daher lädt macOS sie nie, und es wird nichts aus ihr ausgeführt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se puede leer como lista de propiedades o no nombra ninguna tarea, así que macOS nunca lo carga y no se ejecuta nada desde él."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il ne peut pas être lu comme une liste de propriétés, ou il ne désigne aucune tâche : macOS ne le charge donc jamais, et rien ne s’exécute à partir de ce fichier."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non si può leggere come property list, oppure non indica alcun elemento, quindi macOS non lo carica mai e da esso non viene eseguito nulla."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "プロパティリストとして読み取れないか、ジョブが指定されていないため、macOSがこのファイルを読み込むことはなく、このファイルから実行されるものもありません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "속성 목록으로 읽을 수 없거나 작업을 지정하지 않으므로 macOS가 이 파일을 불러오지 않으며, 이 파일로 실행되는 것은 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het kan niet als eigenschappenlijst worden gelezen, of het noemt geen taak, dus macOS laadt het nooit en er wordt niets mee uitgevoerd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie można go odczytać jako listy właściwości albo nie wskazuje żadnego zadania, więc macOS nigdy go nie wczytuje i nic z niego nie jest uruchamiane."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não pode ser lido como lista de propriedades, ou não nomeia nenhuma tarefa, por isso o macOS nunca o carrega e nada é executado a partir dele."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nu poate fi citit ca listă de proprietăți sau nu denumește nicio sarcină, deci macOS nu îl încarcă niciodată și nimic nu rulează din el."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его не удается прочитать как список свойств, или в нем не указано задание, поэтому macOS никогда его не загружает и из него ничего не запускается."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Den kan inte läsas som en egenskapslista, eller så anger den inget jobb, så macOS läser aldrig in den och ingenting körs från den."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Özellik listesi olarak okunamıyor veya hiçbir iş belirtmiyor, bu yüzden macOS onu hiçbir zaman yüklemez ve ondan hiçbir şey çalışmaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його не вдається прочитати як список властивостей, або в ньому не названо жодного завдання, тож macOS ніколи його не завантажує і з нього нічого не запускається."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它无法作为属性列表读取,或者没有指明任何任务,因此macOS从不载入它,也不会有任何内容从它运行。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "無法將它讀取為屬性列表,或它未指名任何工作,因此macOS永遠不會載入它,也不會從它執行任何東西。"
+ }
+ }
+ }
+ },
"It changed after Peel looked at it. Scan again to review it." : {
"localizations" : {
"cs" : {
@@ -153675,6 +153887,112 @@
}
}
},
+ "macOS can’t load this file" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Systém macOS nemůže načíst tento soubor"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS kann diese Datei nicht laden"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS no puede cargar este archivo"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS ne peut pas charger ce fichier"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS non riesce a caricare questo file"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOSはこのファイルを読み込めません"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS가 이 파일을 불러올 수 없음"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS kan dit bestand niet laden"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS nie może wczytać tego pliku"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O macOS não consegue carregar este arquivo"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS nu poate încărca acest fișier"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS не может загрузить этот файл"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS kan inte läsa in den här filen"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS bu dosyayı yükleyemiyor"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS не може завантажити цей файл"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS无法载入此文件"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "macOS無法載入此檔案"
+ }
+ }
+ }
+ },
"macOS couldn’t find the app, so what it was allowed to access is still on record." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
index db2bf8e4..4d2bba57 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
@@ -41,6 +41,9 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {
public let isDisabled: Bool
/// False when only a name points to the owner (`BackgroundItemOwnership.Owner.isConfirmed`).
public var isOwnerConfirmed = true
+ /// True for a file launchd can't load: not a property list, or one without a `Label`. It is named by its file,
+ /// and nothing but moving it is offered.
+ public var isUnreadable = false
/// Includes the file's path, because two files can declare one label (a per-user copy beside the
/// system-wide one), and each file needs a row of its own.
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
index d6898384..bbfa4ede 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
@@ -149,7 +149,10 @@ public enum BackgroundItems {
for plist in plists(in: folder) where !exclusions.excludes(plist) {
// A label of macOS's own is shown too, and marked (`usesALabelOfMacOS`): macOS keeps its jobs
// elsewhere, so a file here that borrows one is somebody else's, and a common way to hide a job.
- guard let job = JobDefinition(contentsOf: plist) else { continue }
+ guard let job = JobDefinition(contentsOf: plist) else {
+ items.append(unreadable(plist, kind: kind, source: source, ownership: ownership))
+ continue
+ }
let owner = ownership.owner(label: job.label, associated: job.associated, program: job.program)
items.append(BackgroundItem(
label: job.label,
@@ -172,6 +175,31 @@ public enum BackgroundItems {
return items
}
+ /// A job file launchd can't load, named by its file since it declares no label that can be read.
+ private static func unreadable(
+ _ plist: URL, kind: BackgroundItem.Kind, source: BackgroundItem.Source, ownership: BackgroundItemOwnership
+ ) -> BackgroundItem {
+ let name = plist.deletingPathExtension().lastPathComponent
+ let owner = ownership.owner(label: name, associated: [], program: nil)
+ return BackgroundItem(
+ label: name,
+ kind: kind,
+ source: source,
+ plistURL: plist,
+ program: nil,
+ runsAtLoad: false,
+ keepsAlive: false,
+ ownerBundleIdentifier: owner?.bundleIdentifier,
+ ownerName: owner?.name,
+ isOwnerInstalled: owner?.isInstalled ?? false,
+ isOrphan: ownership.isOrphan(label: name, program: nil, owner: owner),
+ state: .notLoaded,
+ isDisabled: false,
+ isOwnerConfirmed: owner?.isConfirmed ?? false,
+ isUnreadable: true
+ )
+ }
+
private static func appSubmittedItem(
_ candidate: (label: String, kind: BackgroundItem.Kind, target: String),
ownership: BackgroundItemOwnership,
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 1c9fe891..40b8b501 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -168,12 +168,17 @@ public struct Leftover: Sendable, Hashable, Identifiable {
/// False for what did not answer in time or could not be read: `size` is then zero and means nothing.
public let isMeasured: Bool
public let requiresPrivileges: Bool
+ /// True for a preference file that is no property list (`PreferenceFile.isDamaged`).
+ public var holdsDamagedSettings = false
public var id: URL { url }
/// Returns the same leftover, held back for `reason`: shown, but never selected.
func heldBack(_ reason: HoldBack) -> Leftover {
- Leftover(url: url, kind: kind, match: match.forReview(reason), size: size, isMeasured: isMeasured, requiresPrivileges: requiresPrivileges)
+ Leftover(
+ url: url, kind: kind, match: match.forReview(reason), size: size, isMeasured: isMeasured,
+ requiresPrivileges: requiresPrivileges, holdsDamagedSettings: holdsDamagedSettings
+ )
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
index d515ae24..95326cd8 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift
@@ -290,7 +290,8 @@ public struct LeftoverScanner: Sendable {
match: heldBack.map(match.forReview) ?? match,
size: contents?.size ?? 0,
isMeasured: contents.map { !$0.couldNotBeRead } ?? false,
- requiresPrivileges: parent.requiresPrivileges(toRemove: url)
+ requiresPrivileges: parent.requiresPrivileges(toRemove: url),
+ holdsDamagedSettings: kind == .preferences && PreferenceFile.isDamaged(url)
)
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/PreferenceFile.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/PreferenceFile.swift
new file mode 100644
index 00000000..a120d8ae
--- /dev/null
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/PreferenceFile.swift
@@ -0,0 +1,10 @@
+import Foundation
+
+enum PreferenceFile {
+ /// True for a preference file whose bytes can be read and are not a property list: nothing can read the settings
+ /// in it, the app included.
+ static func isDamaged(_ url: URL) -> Bool {
+ guard url.pathExtension == "plist", let data = BoundedRead.data(at: url) else { return false }
+ return (try? PropertyListSerialization.propertyList(from: data, format: nil)) == nil
+ }
+}
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
index 5312a914..3d9447af 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift
@@ -13,6 +13,8 @@ public struct OrphanItem: Sendable, Hashable, Identifiable {
public var heldBack: HoldBack?
/// The bundle identifier of the app that left, when the item bears its name and nothing else ties the two.
public var namedAfter: String?
+ /// True for a preference file that is no property list (`PreferenceFile.isDamaged`).
+ public var holdsDamagedSettings = false
/// Why the item cannot be selected at all: `RemovalGuard` or the helper would refuse it.
public var leftAlone: HoldBack? {
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
index 92a1b302..858f284e 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift
@@ -350,7 +350,8 @@ public struct OrphanScanner: Sendable {
modificationDate: [own, contents?.newestChange].compactMap(\.self).max(),
requiresPrivileges: parent.requiresPrivileges(toRemove: url),
heldBack: heldBack,
- namedAfter: namedAfter
+ namedAfter: namedAfter,
+ holdsDamagedSettings: location.kind == .preferences && PreferenceFile.isDamaged(url)
)
found.append((identifier, item))
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
index 04a57e4d..5580e5db 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
@@ -27,6 +27,8 @@ public struct BulkUninstallation: Sendable {
public var isPeels = false
/// An app's bundle already in the Trash. Shown, never selected, never counted.
public var isInTheTrash = false
+ /// True for a preference file that is no property list (`PreferenceFile.isDamaged`).
+ public var holdsDamagedSettings = false
public var id: URL { url }
public var isApplication: Bool { match == nil }
@@ -139,7 +141,8 @@ public struct BulkUninstallation: Sendable {
isMeasured: existing.isMeasured || item.isMeasured,
isBeyondTheHelper: existing.isBeyondTheHelper || item.isBeyondTheHelper,
isPeels: existing.isPeels || item.isPeels,
- isInTheTrash: existing.isInTheTrash || item.isInTheTrash
+ isInTheTrash: existing.isInTheTrash || item.isInTheTrash,
+ holdsDamagedSettings: existing.holdsDamagedSettings || item.holdsDamagedSettings
)
} else {
byURL[item.url] = item
@@ -163,7 +166,8 @@ public struct BulkUninstallation: Sendable {
isKeptByMacOS: uninstallation.app.isSystemProtected,
isMeasured: leftover.isMeasured,
isBeyondTheHelper: leftover.match.heldBack == .beyondTheHelper,
- isPeels: uninstallation.isPeel
+ isPeels: uninstallation.isPeel,
+ holdsDamagedSettings: leftover.holdsDamagedSettings
))
}
add(Item(
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
index 40eab269..75c97ee2 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
@@ -128,6 +128,29 @@ struct DeclaredBackgroundItemsTests {
)
}
+ /// A file in these folders that can't be read as a job, not a property list or one without a `Label`, is one
+ /// launchd can't load. It is listed under its file name so it can be moved to the Trash, and nothing else is
+ /// offered for it.
+ @Test func listsAJobFileLaunchdCannotRead() throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/LaunchAgents/org.example.broken.plist", contents: Data("<plist".utf8))
+ let noLabel = try PropertyListSerialization.data(fromPropertyList: ["RunAtLoad": true], format: .xml, options: 0)
+ try directory.file("home/Library/LaunchAgents/org.example.nolabel.plist", contents: noLabel)
+ try directory.file("home/Library/LaunchAgents/org.example.agent.plist", contents: job("org.example.agent"))
+
+ let ownership = BackgroundItemOwnership(installedApps: [])
+ let items = BackgroundItems.declared(in: environment(directory), ownership: ownership)
+
+ let unreadable = items.filter(\.isUnreadable).sorted { $0.label < $1.label }
+ #expect(unreadable.map(\.label) == ["org.example.broken", "org.example.nolabel"])
+ for item in unreadable {
+ #expect(item.state == .notLoaded)
+ #expect(item.canMoveToTrash)
+ #expect(item.program == nil)
+ }
+ #expect(items.filter { !$0.isUnreadable }.map(\.label) == ["org.example.agent"])
+ }
+
/// macOS keeps its own jobs under `/System/Library` and `/Library/Apple/System/Library`, so a file in these
/// folders that uses one of their labels, or any `com.apple.` label, is not macOS's. A label names a job only
/// in its own domain, so such a copy runs beside the real one: it is listed, marked, and never acted on.
@@ -144,8 +167,10 @@ struct DeclaredBackgroundItemsTests {
let items = BackgroundItems.declared(in: environment(directory), ownership: BackgroundItemOwnership(installedApps: []))
- #expect(items.map(\.label).sorted() == ["com.apple.madeup.peeltest", "com.example.agent", "com.example.helper", "com.openssh.ssh-agent", shipped].sorted())
- for borrowed in items where borrowed.label != "com.example.agent" && borrowed.label != "com.example.helper" {
+ let jobs = items.filter { !$0.isUnreadable }
+ let labels = ["com.apple.madeup.peeltest", "com.example.agent", "com.example.helper", "com.openssh.ssh-agent", shipped]
+ #expect(jobs.map(\.label).sorted() == labels.sorted())
+ for borrowed in jobs where borrowed.label != "com.example.agent" && borrowed.label != "com.example.helper" {
#expect(borrowed.usesALabelOfMacOS, "\(borrowed.label)")
#expect(!borrowed.canMoveToTrash, "\(borrowed.label)")
#expect(BackgroundItemActions.refusal(for: borrowed) != nil, "\(borrowed.label)")
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 855d8081..6a38c307 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -69,6 +69,26 @@ struct LeftoverScannerTests {
/// Another copy of an app that macOS knows outside the Applications folders uses the same files. Every Mac has one
/// of the character palette in its input methods folder, so a copy of it in Applications shares its settings, and
/// that copy is counted once when the list of apps holds it too.
+ /// A preference file whose bytes are not a property list holds settings nobody can read, so its row says so. A
+ /// file that reads as one does not.
+ @Test func marksAPreferenceFileThatIsNoPropertyList() async throws {
+ let directory = try TemporaryDirectory()
+ let app = InstalledApp(
+ url: URL(filePath: "/Applications/Hexachord.app"),
+ bundleIdentifier: "org.example.hexachord",
+ name: "Hexachord"
+ )
+ try directory.file("home/Library/Preferences/org.example.hexachord.plist", contents: Data("<plist".utf8))
+ let fine = try PropertyListSerialization.data(fromPropertyList: ["Volume": 3], format: .binary, options: 0)
+ try directory.file("home/Library/Preferences/org.example.hexachord.helper.plist", contents: fine)
+
+ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(app, installedApps: [app])
+
+ let damaged = scan.leftovers.filter(\.holdsDamagedSettings).map(\.url.lastPathComponent)
+ #expect(damaged == ["org.example.hexachord.plist"])
+ #expect(scan.leftovers.contains { $0.url.lastPathComponent == "org.example.hexachord.helper.plist" })
+ }
+
@Test func aCopyMacOSKnowsElsewhereSharesTheAppsFiles() async throws {
let directory = try TemporaryDirectory()
try directory.file("home/Library/Preferences/com.apple.CharacterPaletteIM.plist", bytes: 4096)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index 485b6d54..f78edf40 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -469,6 +469,15 @@ struct OrphanScannerTests {
#expect(Set(scan.groups.flatMap(\.items).map(\.url.lastPathComponent)) == ["Gone.vst3", "Gone Reverb.component"])
}
+ @Test func marksAPreferenceFileThatIsNoPropertyList() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("home/Library/Preferences/org.example.gone.plist", contents: Data("<plist".utf8))
+
+ let items = await scanner(in: directory).scan(installedApps: installed).groups.flatMap(\.items)
+
+ #expect(items.map(\.holdsDamagedSettings) == [true])
+ }
+
/// An app Peel no longer lists has left only when the place it was can be looked at and it is not there. One on
/// a disk that is not connected, or still in a folder Peel stopped looking in, is still installed, and its
/// files are not orphaned.
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 3b208616..25915851 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -581,6 +581,9 @@ struct AppDetailView: View {
if let heldBack = leftover.match.heldBack {
lines.append(String(localized: heldBack.explanation))
}
+ if leftover.holdsDamagedSettings {
+ lines.append(String(localized: "Can’t be read as a property list, so nothing can read these settings."))
+ }
if plan.isPeel {
lines.append(String(localized: "Left alone: Peel removes itself only from Settings."))
}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index 380d49a5..15a3c03f 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -129,7 +129,15 @@ struct BackgroundItemDetailView: View {
}
}
- if item.state == .unknown {
+ if item.isUnreadable {
+ Section {
+ Notice(
+ title: Text("macOS can’t load this file"),
+ detail: Text("It can’t be read as a property list, or it names no job, so macOS never loads it and nothing runs from it."),
+ kind: .note
+ ) {}
+ }
+ } else if item.state == .unknown {
Section {
Notice(
title: Text("Peel can’t tell whether this runs"),
@@ -238,7 +246,7 @@ struct BackgroundItemDetailView: View {
.help(Text(verbatim: item.label))
FlowLayout(spacing: 6) {
stateBadge
- if item.isOrphan {
+ if item.isOrphan, !item.isUnreadable {
NoteBadge(
title: Text("Nothing left to run"), systemImage: "questionmark.circle", tint: .orange,
name: String(localized: "Nothing left to run"),
@@ -275,10 +283,12 @@ struct BackgroundItemDetailView: View {
}
/// Start, Stop, Enable, and Disable, which Peel's own helper, a job under one of macOS's labels, a job whose
- /// state Peel could not read, and a job loaded from a file elsewhere don't have. Disabled, that last one would
- /// leave the list at the next logout or restart with nothing left to Enable it from.
+ /// state Peel could not read, a file macOS can't load, and a job loaded from a file elsewhere don't have.
+ /// Disabled, that last one would leave the list at the next logout or restart with nothing left to Enable it
+ /// from.
private var hasOwnControls: Bool {
!item.isPeelsHelper && !item.usesALabelOfMacOS && item.state != .unknown && item.source != .otherFile
+ && !item.isUnreadable
}
private var controls: some View {
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index 4f487702..1024da6f 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -127,7 +127,12 @@ private struct BackgroundItemRow: View {
Text(item.label)
.lineLimit(1)
.truncationMode(.middle)
- if item.isOrphan {
+ if item.isUnreadable {
+ WarningLabel(title: Text("macOS can’t load this file"))
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
+ } else if item.isOrphan {
WarningLabel(title: Text("Nothing left to run"))
.font(.caption)
.foregroundStyle(.secondary)
diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swift
index b79bc52c..92d8adea 100644
--- a/Peel/Views/MultipleAppsView.swift
+++ b/Peel/Views/MultipleAppsView.swift
@@ -231,6 +231,9 @@ struct MultipleAppsView: View {
if let heldBack = item.match?.heldBack {
lines.append(String(localized: heldBack.explanation))
}
+ if item.holdsDamagedSettings {
+ lines.append(String(localized: "Can’t be read as a property list, so nothing can read these settings."))
+ }
if item.isApplication, item.isBeyondTheHelper {
lines.append(String(localized: HoldBack.beyondTheHelper.explanation))
}
diff --git a/Peel/Views/Orphans/OrphanDetailView.swift b/Peel/Views/Orphans/OrphanDetailView.swift
index f2fabb47..cbe29bf7 100644
--- a/Peel/Views/Orphans/OrphanDetailView.swift
+++ b/Peel/Views/Orphans/OrphanDetailView.swift
@@ -27,7 +27,7 @@ struct OrphanDetailView: View {
icon: .symbol(item.kind.symbolName),
detail: item.modificationDate.map { "Modified \($0, format: .relative(presentation: .named))" },
kind: item.kind.title,
- warning: item.heldBack.map { String(localized: $0.explanation) },
+ warning: warning(for: item),
size: item.size ?? 0,
isMeasured: item.size != nil,
isLocked: item.requiresPrivileges && !helper.canAct,
@@ -56,7 +56,17 @@ struct OrphanDetailView: View {
}
private var hasNoteColumn: Bool {
- group.items.contains { $0.modificationDate != nil || $0.heldBack != nil }
+ group.items.contains { $0.modificationDate != nil || warning(for: $0) != nil }
+ }
+
+ private func warning(for item: OrphanItem) -> String? {
+ let lines = [
+ item.heldBack.map { String(localized: $0.explanation) },
+ item.holdsDamagedSettings
+ ? String(localized: "Can’t be read as a property list, so nothing can read these settings.")
+ : nil,
+ ].compactMap(\.self)
+ return lines.isEmpty ? nil : lines.joined(separator: "\n\n")
}
/// The total size that can be moved to the Trash. Items Peel leaves alone are listed but not counted, as