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
Know a joined copy ending in a name with spaces
Țugui Dragoș1a25f64da064
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dc7ca508..0cf9e9ab 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -647,6 +647,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.#### Duplicates+- A copy Finder names in Japanese, Chinese, or Polish counts as a copy when the name holds a space too, so the original+ is the one kept.- Nothing is compared while the exclusions can't be read, and what is inside an app's document is never offered,even when its app is gone.- A network volume that stops answering no longer holds Peel's threads, a stopped scan says so, and only groups withdiff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swiftindex 762242e9..d9024542 100644--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift@@ -506,22 +506,28 @@ public struct DuplicateFinder: Sendable {static func hasCopySuffix(_ name: String) -> Bool {var words = name.split(separator: " ", omittingEmptySubsequences: false)if words.count == 1 {- return joinedCopyEndings.contains { name.count > $0.count && name.lowercased().hasSuffix($0) }+ return endsInAJoinedCopy(name)}if words.count > 2, words[0].lowercased() == "copie", words[1].lowercased() == "de" { return true }if words[0].lowercased() == "копия" { return true }guard let last = words.popLast() else { return false }if isNumber(last) {- return last.count <= 2 || words.count > 1 && copyWords.contains(words[words.count - 1].lowercased())+ guard last.count > 2, let word = words.last else { return true }+ return words.count > 1 && copyWords.contains(word.lowercased()) || endsInAJoinedCopy(word)}if last.count > 2, last.first == "(", last.last == ")" {let inside = last.dropFirst().dropLast()return isNumber(inside) || copyWords.contains(inside.lowercased())}- return copyWords.contains(last.lowercased())+ return copyWords.contains(last.lowercased()) || endsInAJoinedCopy(last)}- /// What AppKit joins to a name with no space between them, in Japanese, Chinese, and Polish.+ private static func endsInAJoinedCopy(_ word: some StringProtocol) -> Bool {+ let word = word.lowercased()+ return joinedCopyEndings.contains { word.count > $0.count && word.hasSuffix($0) }+ }++ /// What AppKit and Finder join to a name with no space between them, in Japanese, Chinese, and Polish.private static let joinedCopyEndings = ["のコピー", "_副本", "副本", "-kopia"]private static let copyWords: Set<String> = [diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swiftindex 62433411..7689473e 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift@@ -674,6 +674,13 @@ struct DuplicateFinderTests {}}+ @Test func aJoinedCopyEndingCountsInANameWithSpaces() {+ for name in ["年次 報告のコピー", "年度 报告_副本", "Moja umowa-kopia", "年次 報告のコピー 123"] {+ #expect(DuplicateFinder.hasCopySuffix(name), "\(name)")+ }+ #expect(!DuplicateFinder.hasCopySuffix("年次 のコピー報告"))+ }+@Test func aVirtualMachineIsADocumentEvenWithItsAppGone() async throws {let directory = try TemporaryDirectory()let disk = randomData(count: 200_000)