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 which app folders couldn't be read in peel leftovers and uninstall

Țugui Dragoșd8c034596023
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
index 293b49ba..6b304e28 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift
@@ -189,7 +189,7 @@ struct LeftoversCommand: AsyncParsableCommand {
}
func run() async throws {
- let apps = await AppCatalog.installedApps()
+ let apps = AppLookup.apps(from: await AppCatalog.scan())
let target = try AppLookup.app(matching: app, in: apps)
let exclusions = await ExclusionStore().load()
try AppLookup.refuseIfExcluded(target, by: exclusions)
@@ -649,7 +649,7 @@ struct UninstallCommand: AsyncParsableCommand {
}
func run() async throws {
- let apps = await AppCatalog.installedApps()
+ let apps = AppLookup.apps(from: await AppCatalog.scan())
let target = try AppLookup.app(matching: app, in: apps)
if !dryRun {
let carried = await AppExtensions.installed(carriedBy: target)
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/AppLookup.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/AppLookup.swift
index cd687d67..088d5363 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/AppLookup.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/AppLookup.swift
@@ -44,6 +44,13 @@ enum AppLookup {
return exclusions.excludes(app) ? .excluded(app.name) : nil
}
+ /// The apps Peel could read, once it has said what it couldn't: a file shared with an app it didn't see would
+ /// otherwise read as the chosen app's alone.
+ static func apps(from catalog: AppScan) -> [InstalledApp] {
+ if let note = Output.unreadableNote(for: catalog) { Output.note(note) }
+ return catalog.apps
+ }
+
/// Reads a bundle that isn't among the installed apps from the disk. Injected so a test doesn't depend on
/// the folder it runs from.
typealias Inspect = (URL) -> InstalledApp?
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index 7ca6bb54..0f556f53 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -544,6 +544,17 @@ struct CommandLineTests {
== "No leftovers Peel suggests. 11 files need review. Add --all to see them.")
}
+ @Test func leftoversAndUninstallSayWhichAppFoldersCouldNotBeRead() {
+ let folder = URL(filePath: "/Volumes/org.example.Sleeping/Apps")
+ let scan = AppScan(apps: [], unreadable: [folder], needsFullDiskAccess: false)
+ let collected = Output.Collected()
+
+ let apps = Output.$collected.withValue(collected) { AppLookup.apps(from: scan) }
+
+ #expect(apps.isEmpty)
+ #expect(collected.notes.contains(folder.path(percentEncoded: false)))
+ }
+
@Test func theLeftoversReportSaysWhereItCouldNotLook() throws {
let app = InstalledApp(url: URL(filePath: "/Applications/Editor.app", directoryHint: .isDirectory), bundleIdentifier: "com.example.editor", name: "Editor")
let unread = SearchLocation(kind: .containers, url: URL(filePath: "/Users/me/Library/Containers", directoryHint: .isDirectory))