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.

Judge a scan and its move by one reading of the exclusions

Țugui Dragoșd3be78e8a30a
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
index ef50b0fe..bf583c1a 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift
@@ -245,7 +245,7 @@ struct CachesCommand: AsyncParsableCommand {
let all = await ProgressLine.counting { await DeveloperCaches.scan(exclusions: exclusions) }
let environments = try Self.chosen(from: all, named: tools)
guard !remove else {
- return try await clean(environments, using: TrashService(exclusions: await ExclusionStore().load()))
+ return try await clean(environments, using: TrashService(exclusions: exclusions))
}
if output.json {
@@ -421,7 +421,7 @@ struct ProjectsCommand: AsyncParsableCommand {
let artifacts = scan.artifacts
if remove {
Self.notes(for: scan).forEach(Output.note)
- return try await clean(artifacts, using: TrashService(exclusions: await ExclusionStore().load()))
+ return try await clean(artifacts, using: TrashService(exclusions: exclusions))
}
if output.json {
@@ -577,14 +577,15 @@ struct DuplicatesCommand: AsyncParsableCommand {
}
func run() async throws {
- let finder = await DuplicateFinder(exclusions: UnreadableExclusions.load(), digestMemory: DigestMemory())
+ let exclusions = await UnreadableExclusions.load()
+ let finder = DuplicateFinder(exclusions: exclusions, digestMemory: DigestMemory())
let urls = folders.isEmpty ? finder.defaultFolders : folders.map(URL.init(argument:))
let scan = try await ProgressLine.reporting { show in
try await finder.scan(options(for: urls)) { show(Self.progress($0)) }
}
if remove {
Self.notes(for: scan).forEach(Output.note)
- return try await clean(scan, using: TrashService(exclusions: await ExclusionStore().load()))
+ return try await clean(scan, using: TrashService(exclusions: exclusions))
}
if output.json {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
index 96dc023d..cd2c164a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift
@@ -1063,4 +1063,12 @@ struct CommandLineTests {
}
}
}
+
+ @Test func aScanAndItsMoveReadTheExclusionsOnce() throws {
+ let source = try String(
+ contentsOf: LineLengthTests.repository.appending(path: "Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift"),
+ encoding: .utf8
+ )
+ #expect(source.components(separatedBy: "ExclusionStore().load()").count == 1)
+ }
}