removeAbandonedDownloads static method
Deletes the temporary files of downloads into the default cache
directories, models/<id>/ under dataDirectory, that stopped at
least a day ago without removing them, such as one whose process was
killed, whatever model they were for, and returns their paths.
provision does the same for its own model; this serves a host that
cleans its data directory without provisioning again. A download in
progress writes far more often, so its file is kept.
Implementation
static Future<List<String>> removeAbandonedDownloads(
Directory dataDirectory,
) async {
final removed = <String>[];
final models = Directory(p.join(dataDirectory.path, 'models'));
try {
await for (final entry in models.list(followLinks: false)) {
if (entry is! Directory) continue;
removed.addAll(await _removeAbandoned(entry, _anyPartial));
}
} on FileSystemException {
// No model cache yet.
}
return removed;
}