flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

Cached file should be removed on 404, and error should be added to Stream even if a cached file exists

Open ltOgt opened this issue 2 years ago • 0 comments

🐛 Bug Report

Moving https://github.com/Baseflow/flutter_cached_network_image/issues/898 to here.

https://github.com/Baseflow/flutter_cache_manager/blob/32b71c1da1689b97434959ac407b03b74d7e405c/flutter_cache_manager/lib/src/cache_manager.dart#L137-L157

Currently, in CacheManager._pushFileToStream when a cacheFile exists, the cached content is emitted, and if it is outdated, a network request is made to potentially update the file, and emit the updated content.

If a 404 happens on that request, the error is not added to the stream, and the cache is not evicted.

The error is only added if no cacheFile exists.

Expected behavior

On the 404, the cache is evicted (the server is telling us the resource no longer exists) and the error is added to the stream.

Reproduction steps

See https://github.com/Baseflow/flutter_cached_network_image/issues/898

Configuration

Version: 3.1.1

Platform: Tested on macos but should affect all platforms

ltOgt avatar Dec 05 '23 12:12 ltOgt