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
import Foundation
import PeelCore
enum Removals {
/// Records what moved as one batch in History, which the app reads too, and every failure in the log of
/// refusals. An item missing from `sizes` is recorded as unknown. Returns false when History couldn't be written.
static func record(
_ result: TrashResult,
from source: String,
key sourceKey: String? = nil,
sizes: [URL: Int64],
sharingStorage: Set<URL> = [],
tool: String,
in log: RemovalLog = RemovalLog(),
refusals: RefusalLog = RefusalLog()
) async -> Bool {
// History first: it is the way back for what moved, and the refusal log may have to wait for another writer.
var isRecorded = true
if !result.trashed.isEmpty {
let part = RemovalPart(source: source, sourceKey: sourceKey, tool: tool)
let records = part.records(of: result, sizes: sizes, sharingStorage: sharingStorage, batch: UUID())
isRecorded = await log.add(records).records != nil
}
if let problem = await refusals.add(result.failures, source: source, sourceKey: sourceKey, tool: tool) {
Output.note(problem.summary)
}
return isRecorded
}
}