-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
bug : Glide load failed when clear app cache and clearDiskCache #2465
Comments
我出现这个bug的原因是,前面我删除缓存的时候默认把应用的cache都删除了,接着又去删除Glide的磁盘缓存,抛出了这个异常,希望可以帮到你. |
Are you able to attach a sample app that can reproduce this? I'm not able to reproduce either the error attempting to clear the disk cache or a subsequent error using the disk cache. It looks like you might have deleted the directory manually before calling |
That's right. I have cleared the cache directory for the application in settings before calling |
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions. |
listFiles() will return null if the directory has been deleted. This scenario isn’t totally far fetched because it’s fairly common for people to place their disk caches in the application cache directory which can be cleared at any time by the system, including while the app is open. See bumptech/glide#2465 for additional context.
listFiles() will return null if the directory has been deleted. This scenario isn’t totally far fetched because it’s fairly common for Android developers to place their disk caches in the Android application cache directory. The cache directory can be cleared at any time by the system, including while the app is open, which in turn can cause unexpected IOExceptions when delete() is called. See bumptech/glide#2465 for additional context.
Glide Version:4.2.0 and before
Integration libraries:OkHttp3
Device/Android Version:All
Issue details / Repro steps / Use case background:
1.Clear App Cache from system setting
2.Then call GlideApp.get(context).clearDiskCache() , that will cause a exception
log:
W/DiskLruCacheWrapper: Unable to clear disk cache java.io.IOException: not a readable directory: /data/data/com.paisheng.example.pslib/cache/image_manager_disk_cache at com.bumptech.glide.disklrucache.Util.deleteContents(Util.java:55) at com.bumptech.glide.disklrucache.DiskLruCache.delete(DiskLruCache.java:660) at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.clear(DiskLruCacheWrapper.java:143) at com.bumptech.glide.load.engine.Engine.clearDiskCache(Engine.java:326) at com.bumptech.glide.Glide.clearDiskCache(Glide.java:498)
3.Then call GlideApp.with(context).load(url).into(iv) , that will cause a exception
log:
E/GlideExecutor: Request threw uncaught throwable java.lang.IllegalStateException: cache is closed at com.bumptech.glide.disklrucache.DiskLruCache.checkNotClosed(DiskLruCache.java:620) at com.bumptech.glide.disklrucache.DiskLruCache.get(DiskLruCache.java:409) at com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper.get(DiskLruCacheWrapper.java:75) at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:62) at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:293) at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:260) at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:386)
The text was updated successfully, but these errors were encountered: