prune method
Deletes the files last changed longer ago than olderThan, and
returns how many were deleted.
Implementation
Future<int> prune({required Duration olderThan}) => _run('', () async {
_guardWrite('prune');
final DateTime cutoff = DateTime.now().subtract(olderThan);
int removed = 0;
for (final DiskEntry entry in await list('', true)) {
final DateTime? modified = entry.lastModified;
if (!entry.isFile || modified == null || !modified.isBefore(cutoff)) {
continue;
}
final String target = _resolve(entry.path);
if (await driver.delete(target)) removed++;
_written(target);
}
return removed;
});