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
Name a removal of orphaned files as their list names them
Țugui Dragoș3b745a567e69
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex 1fc797a6..beda0b7c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -320,6 +320,24 @@ struct FileCommandTests {#expect(FileManager.default.fileExists(atPath: other.items[0].url.path(percentEncoded: false)))}+ @Test func namesTheRemovalAsTheListNamesTheGroup() async throws {+ let directory = try TemporaryDirectory()+ let logs = logs(in: directory)+ var group = OrphanGroup(identifier: "com.example.gone", items: [try orphan("com.example.gone", in: directory)])+ group.rememberedApp = RememberedApp(+ bundleIdentifier: "com.example.gone", name: "Gone", teamIdentifier: nil, lastSeen: .now,+ lastPath: "/Applications/Gone.app"+ )+ let scan = OrphanScan(groups: [group], unreadableLocations: [])++ try await (command(["orphans", "--remove", "com.example.gone", "-y"]) as OrphansCommand).clean(+ "com.example.gone", in: scan, apps: [], remembered: [], scanner: scanner(in: directory),+ using: try service(in: directory), recordingIn: logs.removals, refusals: logs.refusals+ )++ #expect(await logs.removals.load().records?.map(\.source) == ["Gone"])+ }+/// The command line never uses the helper, so what needs administrator access stays, is recorded as refused,/// and, since nothing else moved, the command exits 1.@Test func leavesWhatNeedsAdministratorAccessAndSaysSo() async throws {diff --git a/Peel/Model/OrphanLibrary.swift b/Peel/Model/OrphanLibrary.swiftindex 48af5039..930c998a 100644--- a/Peel/Model/OrphanLibrary.swift+++ b/Peel/Model/OrphanLibrary.swift@@ -106,13 +106,17 @@ extension OrphanGroup {extension OrphanLibrary: CarriesSelection {var carriedParts: [CarriedSelection.Part] {- (scan?.groups ?? []).compactMap { group in- let selected = selected(in: group)+ Self.parts(of: scan?.groups ?? [], selecting: selectedURLs)+ }++ static func parts(of groups: [OrphanGroup], selecting selectedURLs: Set<URL>) -> [CarriedSelection.Part] {+ groups.compactMap { group in+ let selected = group.items.filter { selectedURLs.contains($0.url) }guard !selected.isEmpty else { return nil }return CarriedSelection.Part(page: group.page,title: group.title,- source: group.identifier,+ source: group.title,sourceKey: nil,sizes: Dictionary(selected.map { ($0.url, $0.size) }, uniquingKeysWith: { first, _ in first }))diff --git a/PeelTests/OrphanPartsTests.swift b/PeelTests/OrphanPartsTests.swiftnew file mode 100644index 00000000..ba413b5f--- /dev/null+++ b/PeelTests/OrphanPartsTests.swift@@ -0,0 +1,24 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++@MainActor+struct OrphanPartsTests {+ @Test func aRemovalOfAGroupIsNamedAsThePageNamesIt() throws {+ let item = OrphanItem(+ url: URL(filePath: "/Users/me/Library/Application Support/org.example.chat"),+ kind: .applicationSupport, size: 10, modificationDate: nil, requiresPrivileges: false+ )+ var group = OrphanGroup(identifier: "org.example.chat", items: [item])+ group.rememberedApp = RememberedApp(+ bundleIdentifier: "org.example.chat", name: "Chat", teamIdentifier: nil, lastSeen: .now,+ lastPath: "/Applications/Chat.app"+ )++ let part = try #require(OrphanLibrary.parts(of: [group], selecting: [item.url]).first)++ #expect(part.title == "Chat")+ #expect(part.source == "Chat")+ }+}