Issue 1:
Dear development team,

I'm using Glide to display product images in my app, e.g. on product detail page:

Glide.with( context )
.load( url )
.thumbnail( Glide.with( context )
.load( placeholderResId )
.apply( new RequestOptions()
.centerCrop() ) )
.into( productImageView );

The caching mechanism of this library is really great to reduce the used bandwidth of the user, but now I have some problem where I need your help:

Given product detail page is displayed along with a product image.

When user deletes product image

and reopens product detail page

Then product image should not be visible anymore (placeholder should be shown).

Problem:

Currently the product image will be loaded from the cache and is displayed to the user which is not expected.

I would like to have the feature to delete a single image in the cache. But I found out, this is not possible.

I found this #552 and decided to go with the 1st solution, although it has some disadvantages for the user (deletion of product images is very rare).

Calling Glide.get( getApplicationContext() ).clearDiskCache(); is not sufficient, because the image could still be in the memory. So I have to call Glide.get( getApplicationContext() ).clearMemory(); as well. But when I want to open the product detail page again, I get the following error message:

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:298)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:265)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)

What do I need to do to "reinitialize" Glide? Or do you have another approach to the problem?

Thanks

Ben

Glide Version: 4.3.1

Integration libraries: OkHttp3

Device/Android Version: Nexus 5X

Issue details / Repro steps / Use case background:

Glide load line / GlideModule (if any) / list Adapter code (if any):

Glide.with...

Layout XML:

<FrameLayout xmlns:android="...

Stack trace / LogCat:

paste stack trace and/or log here

Issue 2:
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)