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
Look for the same copies in peel duplicates as in the app
Țugui Dragoșbff7cd7d0112
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex 3dabd574..bf174130 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -528,7 +528,7 @@ struct DuplicatesCommand: AsyncParsableCommand {@Option(help: "Only files of this kind.")var kind: KindArgument?- @Option(name: .customLong("min-size"), help: "Only files at least this large, and folders holding at least this much, like 500KB or 1.5GB.")+ @Option(name: .customLong("min-size"), help: "Only files at least this large, and folders holding at least this much, like 500KB or 1.5GB, or 0 for every size. Without it, \(DuplicateScanOptions.defaultMinimumSize / 1_000)KB, as in the Peel app.")var minimumSize: ByteSize?@Flag(help: RemovalOptions.movesWhatPeelSuggests)@@ -579,11 +579,8 @@ struct DuplicatesCommand: AsyncParsableCommand {func run() async throws {let finder = await DuplicateFinder(exclusions: UnreadableExclusions.load(), digestMemory: DigestMemory())let urls = folders.isEmpty ? finder.defaultFolders : folders.map(URL.init(argument:))- var options = DuplicateScanOptions(folders: urls)- options.kind = kind?.fileKind ?? .any- options.minimumSize = minimumSize?.bytes ?? 1let scan = try await ProgressLine.reporting { show in- try await finder.scan(options) { show(Self.progress($0)) }+ try await finder.scan(options(for: urls)) { show(Self.progress($0)) }}if remove {Self.notes(for: scan).forEach(Output.note)@@ -611,6 +608,13 @@ struct DuplicatesCommand: AsyncParsableCommand {Self.notes(for: scan).forEach(Output.note)}+ func options(for folders: [URL]) -> DuplicateScanOptions {+ var options = DuplicateScanOptions(folders: folders)+ if let kind { options.kind = kind.fileKind }+ if let minimumSize { options.minimumSize = minimumSize.bytes }+ return options+ }+/// What the scan didn't look at, said on standard error whatever the output, so that an empty answer is not/// read as nothing being there.static func notes(for scan: DuplicateScan) -> [String] {diff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swiftindex ea8b7cd4..cc159974 100644--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swift+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swift@@ -1,11 +1,14 @@public import Foundationpublic struct DuplicateScanOptions: Sendable, Hashable {+ /// The smallest copy Peel looks for unless another size is chosen, in the app and in `peel duplicates` alike.+ public static let defaultMinimumSize: Int64 = 100_000+public var folders: [URL]public var kind = FileKind.any/// The fewest bytes a file holds, or a folder holds in all, to be compared. Never less than one: a copy of/// nothing frees nothing.- public var minimumSize: Int64 = 1 {+ public var minimumSize = defaultMinimumSize {didSet { minimumSize = max(1, minimumSize) }}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackDuplicateTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackDuplicateTests.swiftindex 2f7774b9..e1a8d7d4 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackDuplicateTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackDuplicateTests.swift@@ -15,8 +15,8 @@ struct AttackDuplicateTests {private func scan(_ directory: borrowing TemporaryDirectory, folders: [String]) async throws -> DuplicateScan {let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let options = DuplicateScanOptions(- folders: folders.map { directory.url.appending(path: $0, directoryHint: .isDirectory) }+ let options = DuplicateScanOptions.everySize(+ in: folders.map { directory.url.appending(path: $0, directoryHint: .isDirectory) })return try await DuplicateFinder(homeDirectory: home).scan(options)}@@ -150,7 +150,7 @@ struct AttackDuplicateTests {try directory.file("home/Movies/Old.\(kind)/clip.mov", contents: contents)try directory.file("home/Movies/clip.mov", contents: contents)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))#expect(scan.groups.isEmpty, "ATTACK SUCCEEDED: a file inside a media library was offered")// Two rules stop it, and each is checked: the walk does not go into a library, and the guard refuses whatdiff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackSideEffectTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackSideEffectTests.swiftindex 25dbc929..c34df5a1 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackSideEffectTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackSideEffectTests.swift@@ -74,7 +74,7 @@ struct AttackSideEffectTests {try directory.file("home/Documents/Backups/Preferences/com.adobe.Photoshop.plist", contents: contents)try directory.file("home/Desktop/com.adobe.Photoshop.plist", contents: contents)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let selected = Array(scan.suggestedSelection)#expect(!selected.isEmpty)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DigestMemoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DigestMemoryTests.swiftindex 26f8d2c3..bf35b810 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DigestMemoryTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DigestMemoryTests.swift@@ -11,7 +11,7 @@ struct DigestMemoryTests {private func scan(_ directory: borrowing TemporaryDirectory, memory: DigestMemory) async throws -> DuplicateScan {let home = directory.url.appending(path: "home", directoryHint: .isDirectory)return try await DuplicateFinder(homeDirectory: home, digestMemory: memory)- .scan(DuplicateScanOptions(folders: [home]))+ .scan(.everySize(in: [home]))}private func names(_ scan: DuplicateScan) -> [[String]] {@@ -56,7 +56,7 @@ struct DigestMemoryTests {digestMemory: memory)- let result = try await finder.scan(DuplicateScanOptions(folders: [home]))+ let result = try await finder.scan(.everySize(in: [home]))#expect(names(result).map(Set.init) == [["Documents/first.bin", "Pictures/second.bin"]])let known = memory.load()@@ -73,7 +73,7 @@ struct DigestMemoryTests {let home = directory.url.appending(path: "home", directoryHint: .isDirectory)let result = try await DuplicateFinder(homeDirectory: home, exclusions: .notYetRead, digestMemory: memory)- .scan(DuplicateScanOptions(folders: [home]))+ .scan(.everySize(in: [home]))#expect(result.groups.isEmpty)#expect(memory.load().sample(of: try #require(FileIdentity.of(first))) == nil, "a file was read")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swiftindex 22586868..d3e05f48 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift@@ -36,8 +36,8 @@ struct DuplicateFinderTests {configure: (inout DuplicateScanOptions) -> Void = { _ in }) async throws -> DuplicateScan {let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- var options = DuplicateScanOptions(- folders: folders.map { directory.url.appending(path: $0, directoryHint: .isDirectory) }+ var options = DuplicateScanOptions.everySize(+ in: folders.map { directory.url.appending(path: $0, directoryHint: .isDirectory) })configure(&options)return try await DuplicateFinder(homeDirectory: home).scan(options)@@ -447,7 +447,7 @@ struct DuplicateFinderTests {try directory.file("home/Documents/a.txt", contents: Data("same".utf8))try directory.file("home/Documents/b.txt", contents: Data("same".utf8))let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let options = DuplicateScanOptions(folders: [home])+ let options = DuplicateScanOptions.everySize(in: [home])let task = Task {withUnsafeCurrentTask { $0?.cancel() }@@ -567,7 +567,7 @@ struct DuplicateFinderTests {try photo.prefix(524_288).write(to: url)}- let result = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [volume.url]))+ let result = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [volume.url]))let photos = try #require(result.groups.first { $0.files.contains { $0.url.lastPathComponent == "photo.bin" } })let copy = try #require(photos.files.last)@@ -600,7 +600,7 @@ struct DuplicateRemovalTests {try directory.file("home/Documents/kept.bin", contents: contents)try directory.file("home/Documents/kept copy.bin", contents: contents)let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let files = try #require(scan.groups.first).files#expect(files.map(\.url.lastPathComponent) == ["kept.bin", "kept copy.bin"])return (scan, files[0].url, files[1].url)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/EverySize.swift b/Packages/PeelCore/Tests/PeelCoreTests/EverySize.swiftnew file mode 100644index 00000000..f0c3a6f6--- /dev/null+++ b/Packages/PeelCore/Tests/PeelCoreTests/EverySize.swift@@ -0,0 +1,11 @@+import Foundation+@testable import PeelCore++extension DuplicateScanOptions {+ /// Options that compare copies of every size, since a test's files are smaller than Peel's default.+ static func everySize(in folders: [URL]) -> DuplicateScanOptions {+ var options = DuplicateScanOptions(folders: folders)+ options.minimumSize = 1+ return options+ }+}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex d06d2a1b..39e90e14 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -172,6 +172,21 @@ struct FileCommandTests {// MARK: Duplicates+ /// So `--remove` never moves a small copy the app would not list, such as a license kept in several folders.+ @Test func duplicatesLooksForTheCopiesTheAppLooksFor() throws {+ let folders = [URL(filePath: "/Users/Shared", directoryHint: .isDirectory)]++ let standard = try (command(["duplicates"]) as DuplicatesCommand).options(for: folders)+ let everySize = try (command(["duplicates", "--min-size", "0"]) as DuplicatesCommand).options(for: folders)+ let help = DuplicatesCommand.helpMessage(columns: 300)++ #expect(standard == DuplicateScanOptions(folders: folders))+ #expect(standard.minimumSize == DuplicateScanOptions.defaultMinimumSize)+ #expect(everySize.minimumSize == 1)+ #expect(help.contains("or 0 for every size. Without it, 100KB, as in the Peel app."))+ #expect(ByteSize(argument: "100KB")?.bytes == DuplicateScanOptions.defaultMinimumSize)+ }+/// One copy of every group is always kept, whether the group is of folders or of files.@Test func keepsOneCopyOfEveryDuplicateGroup() async throws {let directory = try TemporaryDirectory()@@ -183,7 +198,7 @@ struct FileCommandTests {try directory.file("home/Documents/lonely.bin", contents: Data(repeating: 7, count: 4_000))try directory.file("home/Documents/lonely copy.bin", contents: Data(repeating: 7, count: 4_000))let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let keptFolder = try #require(scan.folderGroups.first?.folders.first?.url)let keptFile = try #require(scan.groups.first?.files.first?.url)@@ -202,7 +217,7 @@ struct FileCommandTests {try directory.file("home/Documents/a.bin", contents: contents)try directory.file("home/Documents/a copy.bin", contents: contents)let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))try await (command(["duplicates", "--remove", "--dry-run"]) as DuplicatesCommand).clean(scan, using: try service(in: directory), recordingIn: logs.removals, refusals: logs.refusals)@@ -220,7 +235,7 @@ struct FileCommandTests {try directory.file("home/Documents/a.bin", contents: contents)try directory.file("home/Documents/a copy.bin", contents: contents)let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let kept = try #require(scan.groups.first?.files.first?.url)let collected = Output.Collected()@@ -439,7 +454,7 @@ struct FileCommandTests {try directory.file("home/Documents/a copy.bin", contents: contents)try directory.file("home/Pictures/a.bin", contents: contents)let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let group = try #require(scan.groups.first)let rows = DuplicatesCommand.rows(for: group.files.map(\.url))@@ -457,7 +472,7 @@ struct FileCommandTests {try directory.file("\(folder)/photo.jpg", contents: contents)}let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let group = try #require(scan.folderGroups.first)#expect(DuplicatesCommand.heading(for: group).hasPrefix("2 copies of a folder of 1 file, 4 kB, "))diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FolderDuplicateTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FolderDuplicateTests.swiftindex 3f068c29..9a1885d8 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FolderDuplicateTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FolderDuplicateTests.swift@@ -14,8 +14,8 @@ struct FolderDuplicateTests {configure: (inout DuplicateScanOptions) -> Void = { _ in }) async throws -> DuplicateScan {let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- var options = DuplicateScanOptions(- folders: folders.map { directory.url.appending(path: $0, directoryHint: .isDirectory) }+ var options = DuplicateScanOptions.everySize(+ in: folders.map { directory.url.appending(path: $0, directoryHint: .isDirectory) })configure(&options)return try await DuplicateFinder(homeDirectory: home).scan(options)@@ -236,7 +236,7 @@ struct FolderDuplicateTests {let exclusions = Exclusions(paths: [directory.url.appending(path: "home/Documents/Work/keep.pdf")])let result = try await DuplicateFinder(homeDirectory: home, exclusions: exclusions)- .scan(DuplicateScanOptions(folders: [home]))+ .scan(.everySize(in: [home]))#expect(result.folderGroups.isEmpty)}@@ -411,7 +411,7 @@ struct FolderDuplicateRemovalTests {try directory.file("home/Documents/Trip/photo.jpg", contents: contents)try directory.file("home/Pictures/Trip/photo.jpg", contents: contents)let home = directory.url.appending(path: "home", directoryHint: .isDirectory)- let scan = try await DuplicateFinder(homeDirectory: home).scan(DuplicateScanOptions(folders: [home]))+ let scan = try await DuplicateFinder(homeDirectory: home).scan(.everySize(in: [home]))let folders = try #require(scan.folderGroups.first).folders#expect(folders.count == 2)return (scan, folders[0].url, folders[1].url)diff --git a/Peel/Model/DuplicateLibrary.swift b/Peel/Model/DuplicateLibrary.swiftindex 4f559e88..941685c8 100644--- a/Peel/Model/DuplicateLibrary.swift+++ b/Peel/Model/DuplicateLibrary.swift@@ -19,7 +19,7 @@ final class DuplicateLibrary {}}var kind = FileKind.any- var minimumSize: Int64 = 100_000+ var minimumSize = DuplicateScanOptions.defaultMinimumSizeprivate(set) var scan: DuplicateScan? {didSet { readScan() }}diff --git a/README.md b/README.mdindex dc33c97e..c0dd2852 100644--- a/README.md+++ b/README.md@@ -119,6 +119,8 @@ Peel is free and open source, and it speaks English and 17 other languages.whose name says nothing on its own. Until you choose a folder, Peel offers `~/Developer`, `~/Projects`, `~/Code`,or `~/src` when you have one, and adds it only when you say so.- **Duplicates:** files and whole folders with identical contents, compared with SHA-256. One copy is always kept.+ Files under 100 KB, and folders holding less, are left out unless you choose a smaller size, in the app and in+ `peel duplicates` alike.- **Installers and Backups:** installers of apps you already have, including packages an app keeps in ApplicationSupport, macOS installers, device firmware, downloads a browser never finished, updates apps downloaded and keepuntil they install them, and what your iPhone backups hold. Nothing is selected for you.diff --git a/Support/peel.1 b/Support/peel.1index 3e658981..8d7bc1ef 100644--- a/Support/peel.1+++ b/Support/peel.1@@ -1,5 +1,5 @@.\" "Generated by swift-argument-parser"-.Dd September 28, 2026+.Dd October 5, 2026.Dt PEEL 1.Os.Sh NAME@@ -255,7 +255,7 @@ Zip files and other archivesDisk images, such as .dmg files.El.It Fl -min-size Ar min-size-Only files at least this large, and folders holding at least this much, like 500KB or 1.5GB.+Only files at least this large, and folders holding at least this much, like 500KB or 1.5GB, or 0 for every size. Without it, 100KB, as in the Peel app..It Fl -removeMove what Peel suggests to the Trash..It Fl -dry-run