jimu-decompiled/sources/com/bumptech/glide/load/engine/cache/DiskLruCacheWrapper.java
2025-05-13 19:24:51 +02:00

113 lines
3.4 KiB
Java

package com.bumptech.glide.load.engine.cache;
import android.util.Log;
import com.bumptech.glide.disklrucache.DiskLruCache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
import java.io.IOException;
/* loaded from: classes.dex */
public class DiskLruCacheWrapper implements DiskCache {
private final File b;
private final long c;
private DiskLruCache e;
private final DiskCacheWriteLocker d = new DiskCacheWriteLocker();
private final SafeKeyGenerator a = new SafeKeyGenerator();
@Deprecated
protected DiskLruCacheWrapper(File file, long j) {
this.b = file;
this.c = j;
}
public static DiskCache a(File file, long j) {
return new DiskLruCacheWrapper(file, j);
}
private synchronized void b() {
this.e = null;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public synchronized void clear() {
try {
try {
a().a();
} catch (IOException e) {
if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
Log.w("DiskLruCacheWrapper", "Unable to clear disk cache or disk cache cleared externally", e);
}
}
} finally {
b();
}
}
private synchronized DiskLruCache a() throws IOException {
if (this.e == null) {
this.e = DiskLruCache.a(this.b, 1, 1, this.c);
}
return this.e;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public File a(Key key) {
String a = this.a.a(key);
if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
Log.v("DiskLruCacheWrapper", "Get: Obtained: " + a + " for for Key: " + key);
}
try {
DiskLruCache.Value b = a().b(a);
if (b != null) {
return b.a(0);
}
return null;
} catch (IOException e) {
if (!Log.isLoggable("DiskLruCacheWrapper", 5)) {
return null;
}
Log.w("DiskLruCacheWrapper", "Unable to get from disk cache", e);
return null;
}
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void a(Key key, DiskCache.Writer writer) {
DiskLruCache a;
String a2 = this.a.a(key);
this.d.a(a2);
try {
if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
Log.v("DiskLruCacheWrapper", "Put: Obtained: " + a2 + " for for Key: " + key);
}
try {
a = a();
} catch (IOException e) {
if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
Log.w("DiskLruCacheWrapper", "Unable to put to disk cache", e);
}
}
if (a.b(a2) != null) {
return;
}
DiskLruCache.Editor a3 = a.a(a2);
if (a3 != null) {
try {
if (writer.a(a3.a(0))) {
a3.c();
}
a3.b();
return;
} catch (Throwable th) {
a3.b();
throw th;
}
}
throw new IllegalStateException("Had two simultaneous puts for: " + a2);
} finally {
this.d.b(a2);
}
}
}