Skip to content

Commit c07c67b

Browse files
committed
fix orphaned cache cleanup
1 parent 0fb00d7 commit c07c67b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/cache_manager.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ class CustomCacheManager {
2323
return;
2424
}
2525

26-
final allFiles = cacheDir.listSync(recursive: true).toList();
26+
final allFiles =
27+
cacheDir.listSync(recursive: true).whereType<File>().toList();
2728

2829
await _repo.open();
2930
final cachedObjects = await _repo.getAllObjects();
3031
final dbFiles = cachedObjects.map((e) => e.relativePath).toSet();
3132

3233
final orphanedFiles = allFiles.where((file) {
33-
final relativePath = file.path.split('$key/').last;
34+
final relativePath = file.path.replaceFirst('${cacheDir.path}/', '');
3435
return !dbFiles.contains(relativePath);
3536
}).toList();
3637

0 commit comments

Comments
 (0)