You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a new disk cache, or {@code null} if no disk cache could be created.
and Engine.LazyDiskCacheProvider.getDiskCache() just returns the value,
then DecodeJob uses that return value in a chain: diskCacheProvider.getDiskCache().get|put|delete().
Meaning a custom Disk Cache Factory may fail:
public static class GlideSetup implements GlideModule {
@Override public void applyOptions(final Context context, GlideBuilder builder) {
builder.setDiskCache(new DiskCache.Factory() {
@Override public DiskCache build() {
File cacheDir = Paths.getGlideCacheDirectory(context);
if (cacheDir == null
|| (!cacheDir.mkdirs() && (!cacheDir.exists() || !cacheDir.isDirectory()))) {
// Note that the condition is almost the same as Glide.getPhotoCacheDir
return null;
}
return DiskLruCacheWrapper.get(cacheDir, 250 * 1024 * 1024);
}
});
}
@Override public void registerComponents(Context context, Glide glide) {}
}
In case the DiskCache.Factory can't create a cache (no available directory, the a App will crash with an NPE in Glide, however it could probably work just fine without a disk cache, maybe a little slower.
Probably the
if (diskCache == null) {
diskCache = new DiskCacheAdapter();
}
lines in InternalCacheDiskCacheFactory.build should be moved to LazyDiskCacheProvider, so the fallback applies to all caches, not just the Glide built-in one.
PS: Also note that's an awful lot of lines, just to move the disk cache to another directory.
The text was updated successfully, but these errors were encountered:
Glide Version/Integration library (if any): 3.5.2
Device/Android Version: N/A
Issue details/Repro steps:
DiskCache.Factory.build()
method JavaDoc saysand
Engine.LazyDiskCacheProvider.getDiskCache()
just returns the value,then
DecodeJob
uses that return value in a chain:diskCacheProvider.getDiskCache().get|put|delete()
.Meaning a custom Disk Cache Factory may fail:
In case the DiskCache.Factory can't create a cache (no available directory, the a App will crash with an NPE in Glide, however it could probably work just fine without a disk cache, maybe a little slower.
Probably the
lines in
InternalCacheDiskCacheFactory.build
should be moved toLazyDiskCacheProvider
, so the fallback applies to all caches, not just the Glide built-in one.PS: Also note that's an awful lot of lines, just to move the disk cache to another directory.
The text was updated successfully, but these errors were encountered: