clean method
Implementation
Future<CleanupResult> clean(
CleanupTarget target, {
required bool dryRun,
}) async {
if (!_fileSystem.exists(target.path)) {
if (target.command != null) {
return _runCommand(target);
}
return CleanupResult(
target: target,
bytesReclaimed: 0,
deleted: false,
skippedReason: 'missing',
);
}
if (target.contentsOnly) {
return _cleanContents(target, dryRun: dryRun);
}
final size = await _fileSystem.sizeOf(target.path);
final deleted = await _fileSystem.delete(target.path, dryRun: dryRun);
return CleanupResult(
target: target,
bytesReclaimed: deleted ? size : 0,
deleted: deleted,
skippedReason: deleted ? null : 'protected',
);
}