Skip to content

Commit 942bc8d

Browse files
ltOgtmartijn00
authored andcommitted
evict and add only on 404
1 parent 0e06a32 commit 942bc8d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flutter_cache_manager/lib/src/cache_manager.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ class CacheManager implements BaseCacheManager {
151151
cacheLogger.log(
152152
'CacheManager: Failed to download file from $url with error:\n$e',
153153
CacheManagerLogLevel.debug);
154-
if (streamController.hasListener) {
154+
if (cacheFile == null && streamController.hasListener) {
155155
streamController.addError(e);
156156
}
157-
if (cacheFile != null) {
157+
158+
if (cacheFile != null && e is HttpExceptionWithStatus && e.statusCode == 404) {
159+
streamController.addError(e);
158160
await removeFile(key);
159161
}
160162
}

0 commit comments

Comments
 (0)