flutter_cached_network_image
flutter_cached_network_image copied to clipboard
FileSystemException: Cannot delete file
Sentry keeps reporting issues in my app that looks like this:
FileSystemException: Cannot delete file, path = '/data/user/0/<PACKAGE>/cache/cacheKey/23c5a2c0-f0e3-11ec-8c0e-df065a5f9164.webp' (OS Error: No such file or directory, errno = 2)
Sentry specifies that the error occurs in cache_store.dart in CacheStore._removeCachedFile at line 190 within flutter_cache_manager
I do not know the cause, as I have been unable to recreate it. About two years ago this issue was reported, which I believe is associated with the problem.
We are using cached_network_image: 3.2.1
which inside uses flutter_cache_manager 3.3.0
got this issue in my app too
Similarly, I also got an error. The version I am using is 3.2.2.
FileSystemException: FileSystemException: Cannot delete file, path = '/data/user/0/com.xxx.xxx/cache/libCachedImageData/1ac62930-29e4-11ed-bce3-81be1b9f6831.octet-stream' (OS Error: No such file or directory, errno = 2)
It gave too many warnings before this error.
Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction
I caught the exception while debugging, so:
-
Where the exception was thrown:
-
The parent caller:
It seems that after checking that the file exists… it got removed before removing it? 👀
got this issue in my app too
Any update on this?
We are also seeing this
I have the same issue. If there was a way to wrap the CacheStore with a version that logs and ignores the error (if the file is missing or already deleted, it should just skip it) that would be great.
Although it doesn't address the root cause, I think ignoring this particular exception would be ok. Although if the root issue is resolved, this should never happen, I think we can ignore the error.
I made a fork solution here: https://github.com/ddikman/flutter_cache_manager/blob/develop/flutter_cache_manager/lib/src/cache_store.dart#L190-L198
FWIW, we have changed our cache policy from a time based(3d) to count based(1000) and stopped seeing this error. We would have liked a size based (25MB) option, but count based is a reasonable proxy. It should apply to most other applications as well ✌️