Skip to content

Commit

Permalink
Merge pull request #370 from banool/develop
Browse files Browse the repository at this point in the history
Await futures in emptyCache
  • Loading branch information
martijn00 authored Aug 13, 2024
2 parents a42c7c8 + 5ede802 commit 55ea36e
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 55ea36e

Please sign in to comment.