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 one copy that stays in the singular in peel duplicates

Țugui Dragoș9d5f5c768562
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
index e07ea653..f1123bcd 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
@@ -867,18 +867,22 @@ struct DuplicatesCommand: AsyncParsableCommand {
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 == .inTheCloud } }
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.")
+ notes.append("\(Output.count(synced, "copy syncs", "copies sync")) to your other devices, so Peel lists \(asCopies(synced)).")
notes += keepers(of: scan.groups.flatMap(\.files)).compactMap(\.note)
}
let staying = scan.groups.reduce(0) { total, group in
total + group.files.count { $0.heldBack == .keepsWhatTheOthersLack }
}
if staying > 0 {
- notes.append("\(Output.count(staying, "copy has", "copies have")) Finder tags, a Finder comment, or a resource fork the others lack, so Peel lists them as copies that stay and never moves them.")
+ notes.append("\(Output.count(staying, "copy has", "copies have")) Finder tags, a Finder comment, or a resource fork the others lack, so Peel lists \(asCopies(staying)).")
}
return notes
}
+ private static func asCopies(_ count: Int) -> String {
+ count == 1 ? "it as a copy that stays and never moves it" : "them as copies that stay and never moves them"
+ }
+
/// The apps that sync the copies held back for syncing through one, each marker once, in the order found.
static func keepers(of files: [DuplicateFile]) -> [SyncKeeper] {
files.filter { $0.heldBack == .inTheCloud }.compactMap(\.syncedBy).reduce(into: []) { keepers, keeper in
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
index 9d72ffc1..d7aeac10 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift
@@ -597,6 +597,9 @@ struct FileCommandTests {
let group = try #require(scan.groups.first)
#expect(DuplicatesCommand.rows(for: group).map { $0[0] }.sorted() == ["", "stays"])
+ #expect(DuplicatesCommand.notes(for: scan).contains(
+ "1 copy has Finder tags, a Finder comment, or a resource fork the others lack, so Peel lists it as a copy that stays and never moves it."
+ ))
let json = try Output.jsonText(DuplicatesCommand.found(in: scan))
let found = try #require(JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any])
let record = try #require((found["files"] as? [[String: Any]])?.first)