Skip to content
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

Closed
yxcSini opened this issue Oct 11, 2017 · 4 comments
Closed

bug : Glide load failed when clear app cache and clearDiskCache #2465

yxcSini opened this issue Oct 11, 2017 · 4 comments
Labels
Milestone

Comments

@yxcSini
Copy link

yxcSini commented Oct 11, 2017

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)

@sjudd sjudd added the bug label Oct 11, 2017
@cccfly-bake
Copy link

我出现这个bug的原因是,前面我删除缓存的时候默认把应用的cache都删除了,接着又去删除Glide的磁盘缓存,抛出了这个异常,希望可以帮到你.

@sjudd sjudd added repro-needed and removed bug labels Nov 13, 2017
@sjudd
Copy link
Collaborator

sjudd commented Nov 13, 2017

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 clearDiskCache()? Or cleared the cache directory for the application in settings?

sjudd added a commit to sjudd/glide that referenced this issue Nov 13, 2017
@yxcSini
Copy link
Author

yxcSini commented Nov 20, 2017

That's right. I have cleared the cache directory for the application in settings before calling clearDiskCache(). @sjudd

@stale
Copy link

stale bot commented Nov 27, 2017

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.

@stale stale bot added the stale label Nov 27, 2017
@sjudd sjudd added this to the 4.4 milestone Nov 27, 2017
sjudd added a commit to sjudd/DiskLruCache that referenced this issue Nov 27, 2017
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.
sjudd added a commit to sjudd/DiskLruCache that referenced this issue Nov 27, 2017
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.
@sjudd sjudd closed this as completed in 16eaa9b Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants