fix & improve DownloadedPage

This commit is contained in:
wgh136
2024-05-21 14:59:09 +08:00
parent 5ae73bd7c8
commit 1a224114fc
3 changed files with 248 additions and 190 deletions

View File

@@ -368,6 +368,26 @@ class DownloadManager {
}
}
Future<void> checkAndClearInvalidItems() async{
var illusts = listAll();
var shouldDelete = <DownloadedIllust>[];
for(var item in illusts) {
var paths = getImagePaths(item.illustId);
var validPaths = <String>[];
for(var path in paths) {
if(await File(path).exists()) {
validPaths.add(path);
}
}
if(validPaths.isEmpty) {
shouldDelete.add(item);
}
}
for(var item in shouldDelete) {
delete(item);
}
}
void resume() {
_paused = false;
}