Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Await futures in emptyCache #370

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flutter_cache_manager/lib/src/cache_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ class CacheStore {
final provider = await _cacheInfoRepository;
final toRemove = <int>[];
final allObjects = await provider.getAllObjects();
var futures = <Future>[];
for (final cacheObject in allObjects) {
_removeCachedFile(cacheObject, toRemove);
futures.add(_removeCachedFile(cacheObject, toRemove));
}
await Future.wait(futures);
await provider.deleteAll(toRemove);
}

Expand All @@ -180,7 +182,7 @@ class CacheStore {
_memCache.remove(cacheObject.key);
}
if (_futureCache.containsKey(cacheObject.key)) {
_futureCache.remove(cacheObject.key);
await _futureCache.remove(cacheObject.key);
}
final file = io.File(cacheObject.relativePath);

Expand Down