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
Have peel duplicates say why it skips a folder and when nothing can move
Țugui Dragoșec55dd0143f6
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex d7e6379d..6955b08e 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -756,6 +756,13 @@ struct DuplicatesCommand: AsyncParsableCommand {let unreadableLocations: [String]/// Chosen folders the scan didn't look in.let skippedLocations: [String]+ /// The same folders, each with why it wasn't looked in.+ let setAside: [SetAside]+ }++ struct SetAside: Encodable {+ let path: String+ let reason: String}/// Checks the folders here rather than in `run()`: only while it parses does ArgumentParser know which@@ -769,9 +776,9 @@ struct DuplicatesCommand: AsyncParsableCommand {guard missing.isEmpty else {throw ValidationError("\(missing.map(Output.path).joined(separator: ", ")): no such folder.")}- let rejected = urls.filter { !finder.canScan($0) }+ let rejected = urls.compactMap { url in finder.refusal(of: url).map { "\(Output.path(url)): \($0.summary)" } }guard rejected.isEmpty else {- throw ValidationError("Peel can't scan \(rejected.map(Output.path).joined(separator: ", ")). Choose folders in your home folder, /Users/Shared, or a disk Peel can write to. App data, the Music and TV apps' media folders, apps and other packages, and system folders aren't scanned.")+ throw ValidationError(rejected.joined(separator: "\n"))}}@@ -832,10 +839,7 @@ struct DuplicatesCommand: AsyncParsableCommand {Output.unreadableNote(for: scan.unreadableLocations, needsFullDiskAccess: scan.needsFullDiskAccess))}- if !scan.skippedLocations.isEmpty {- let folders = scan.skippedLocations.map { Output.path($0.url) }.joined(separator: ", ")- notes.append("Peel didn't look in \(folders), so there may be duplicates there. It leaves repositories alone, and doesn't scan app data or system folders.")- }+ notes += scan.skippedLocations.map { "Peel didn't look in \(Output.path($0.url)): \($0.reason.summary)." }let synced = scan.groups.reduce(0) { total, group in total + group.files.count { $0.heldBack != nil } }if synced > 0 {notes.append("\(Output.count(synced, "copy syncs", "copies sync")) to your other devices, so Peel lists them as copies that stay and never moves them.")@@ -862,7 +866,8 @@ struct DuplicatesCommand: AsyncParsableCommand {)},unreadableLocations: scan.unreadableLocations.map(Output.path),- skippedLocations: scan.skippedLocations.map { Output.path($0.url) }+ skippedLocations: scan.skippedLocations.map { Output.path($0.url) },+ setAside: scan.skippedLocations.map { SetAside(path: Output.path($0.url), reason: $0.reason.summary) })}@@ -908,7 +913,10 @@ struct DuplicatesCommand: AsyncParsableCommand {let folders = scan.folderGroups.flatMap { $0.folders.dropFirst() }let files = scan.groups.flatMap { $0.movableFiles.dropFirst() }guard !folders.isEmpty || !files.isEmpty else {- Output.line("No duplicates found.")+ Output.line(+ scan.groups.isEmpty && scan.folderGroups.isEmpty+ ? "No duplicates found." : "Nothing to move: every other copy syncs to your other devices."+ )return}// Where each group's kept copy is comes first, and the copies that sync, which stay: it is what thediff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 4d67619b..fedea610 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -403,6 +403,18 @@ extension HoldBack {}}+extension DuplicateFinder.Refusal {+ var summary: String {+ switch self {+ case .appData: "it is app data, the Music or TV app's media folder, or something Peel protects, such as a photo library or a keychain"+ case .inAPackage: "it is an app or another package, or inside one, and what is inside belongs to it"+ case .outsideTheHome: "it is outside your home folder and /Users/Shared, or on a disk Peel can't write to"+ case .insideARepository: "it is a repository, or sits inside one, and Peel leaves repositories alone"+ case .notAFolder: "it isn't a folder Peel can reach"+ }+ }+}+extension ProjectArtifacts.Refusal {var summary: String {switch self {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex ed12fe85..bc9e5a81 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -685,7 +685,41 @@ struct FileCommandTests {let notes = DuplicatesCommand.notes(for: scan)- #expect(notes.contains { $0.hasPrefix("Peel didn't look in /Users/me/Projects/app, so there may be duplicates there.") })+ #expect(notes.contains {+ $0 == "Peel didn't look in /Users/me/Projects/app: it is a repository, or sits inside one, and Peel leaves repositories alone."+ })+ }++ @Test func refusesEachFolderItCantScanWithItsReason() throws {+ let finder = "/System/Library/CoreServices/Finder.app"+ let error = #expect(throws: (any Error).self) {+ try PeelCommand.parseAsRoot(["duplicates", "/Applications", finder])+ }++ let message = PeelCommand.fullMessage(for: try #require(error), columns: 300)++ #expect(message.contains("/Applications: it is outside your home folder and /Users/Shared, or on a disk Peel can't write to"))+ #expect(message.contains("\(finder): it is an app or another package, or inside one, and what is inside belongs to it"))+ }++ @Test func saysThereIsNothingToMoveWhenEveryOtherCopySyncs() async throws {+ let directory = try TemporaryDirectory()+ let logs = logs(in: directory)+ let contents = Data((0..<4_000).map { _ in UInt8.random(in: 0...255) })+ try directory.directory("home/Synced/.stfolder")+ try directory.file("home/Synced/a.bin", contents: contents)+ try directory.file("home/Documents/a.bin", contents: contents)+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))+ let collected = Output.Collected()++ try await Output.$collected.withValue(collected) {+ try await (command(["duplicates", "--remove", "--dry-run"]) as DuplicatesCommand)+ .clean(scan, using: try service(in: directory), recordingIn: logs.removals, refusals: logs.refusals)+ }++ #expect(scan.groups.count == 1)+ #expect(collected.output == "Nothing to move: every other copy syncs to your other devices.\n")}@Test func duplicatesComparesNothingWhileTheExclusionsCantBeRead() {@@ -714,6 +748,10 @@ struct FileCommandTests {let found = try #require(JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any])#expect(found["unreadableLocations"] as? [String] == ["/Users/me/Locked"])#expect(found["skippedLocations"] as? [String] == ["/Users/me/Projects/app"])+ #expect(found["setAside"] as? [[String: String]] == [[+ "path": "/Users/me/Projects/app",+ "reason": "it is a repository, or sits inside one, and Peel leaves repositories alone",+ ]])}@Test func aRemovalFromTwoProjectsOfTheSameNameIsNotNamedForOne() {