2021-12-21 23:37:30 +00:00
|
|
|
package b.f.j.c;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.f.b.b.d;
|
|
|
|
import b.f.b.b.h;
|
|
|
|
import b.f.b.b.i;
|
|
|
|
import b.f.d.g.g;
|
|
|
|
import b.f.d.g.j;
|
|
|
|
import b.f.j.j.e;
|
|
|
|
import b.f.j.r.b;
|
2021-06-27 20:44:35 +00:00
|
|
|
import com.facebook.cache.common.CacheKey;
|
|
|
|
import com.facebook.common.memory.PooledByteBuffer;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
/* compiled from: BufferedDiskCache */
|
|
|
|
public class f {
|
|
|
|
public final h a;
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
|
|
|
public final g f545b;
|
|
|
|
public final j c;
|
2021-06-27 20:44:35 +00:00
|
|
|
public final Executor d;
|
|
|
|
public final Executor e;
|
|
|
|
public final a0 f = new a0();
|
|
|
|
public final r g;
|
|
|
|
|
|
|
|
/* compiled from: BufferedDiskCache */
|
|
|
|
public class a implements Runnable {
|
2021-12-17 22:03:14 +00:00
|
|
|
public final /* synthetic */ CacheKey j;
|
|
|
|
public final /* synthetic */ e k;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
|
|
|
public a(Object obj, CacheKey cacheKey, e eVar) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.j = cacheKey;
|
|
|
|
this.k = eVar;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:10:0x002c, code lost:
|
|
|
|
if (r1 != null) goto L_0x002e;
|
|
|
|
*/
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:11:0x002e, code lost:
|
|
|
|
r1.close();
|
|
|
|
*/
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0031, code lost:
|
|
|
|
throw r0;
|
|
|
|
*/
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:8:0x001e, code lost:
|
|
|
|
r0 = move-exception;
|
|
|
|
*/
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:9:0x001f, code lost:
|
2021-12-17 22:03:14 +00:00
|
|
|
r4.l.f.d(r4.j, r4.k);
|
|
|
|
r1 = r4.k;
|
2021-06-27 20:44:35 +00:00
|
|
|
*/
|
|
|
|
@Override // java.lang.Runnable
|
|
|
|
public void run() {
|
2021-12-17 22:03:14 +00:00
|
|
|
f.b(f.this, this.j, this.k);
|
|
|
|
f.this.f.d(this.j, this.k);
|
|
|
|
e eVar = this.k;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (eVar != null) {
|
|
|
|
eVar.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public f(h hVar, g gVar, j jVar, Executor executor, Executor executor2, r rVar) {
|
|
|
|
this.a = hVar;
|
2021-12-21 23:37:30 +00:00
|
|
|
this.f545b = gVar;
|
|
|
|
this.c = jVar;
|
2021-06-27 20:44:35 +00:00
|
|
|
this.d = executor;
|
|
|
|
this.e = executor2;
|
|
|
|
this.g = rVar;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: finally extract failed */
|
|
|
|
public static PooledByteBuffer a(f fVar, CacheKey cacheKey) throws IOException {
|
|
|
|
Objects.requireNonNull(fVar);
|
|
|
|
try {
|
|
|
|
cacheKey.b();
|
2021-12-21 23:37:30 +00:00
|
|
|
int i = b.f.d.e.a.a;
|
|
|
|
b.f.a.a b2 = ((d) fVar.a).b(cacheKey);
|
|
|
|
if (b2 == null) {
|
2021-06-27 20:44:35 +00:00
|
|
|
cacheKey.b();
|
|
|
|
Objects.requireNonNull((z) fVar.g);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
cacheKey.b();
|
|
|
|
Objects.requireNonNull((z) fVar.g);
|
2021-12-21 23:37:30 +00:00
|
|
|
FileInputStream fileInputStream = new FileInputStream(b2.a);
|
2021-06-27 20:44:35 +00:00
|
|
|
try {
|
2021-12-21 23:37:30 +00:00
|
|
|
PooledByteBuffer d = fVar.f545b.d(fileInputStream, (int) b2.a());
|
2021-06-27 20:44:35 +00:00
|
|
|
fileInputStream.close();
|
|
|
|
cacheKey.b();
|
|
|
|
return d;
|
|
|
|
} catch (Throwable th) {
|
|
|
|
fileInputStream.close();
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
2021-12-21 23:37:30 +00:00
|
|
|
b.f.d.e.a.n(f.class, e, "Exception reading from cache for %s", cacheKey.b());
|
2021-06-27 20:44:35 +00:00
|
|
|
Objects.requireNonNull((z) fVar.g);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void b(f fVar, CacheKey cacheKey, e eVar) {
|
|
|
|
Objects.requireNonNull(fVar);
|
|
|
|
cacheKey.b();
|
2021-12-21 23:37:30 +00:00
|
|
|
int i = b.f.d.e.a.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
try {
|
|
|
|
((d) fVar.a).d(cacheKey, new h(fVar, eVar));
|
|
|
|
Objects.requireNonNull((z) fVar.g);
|
|
|
|
cacheKey.b();
|
|
|
|
} catch (IOException e) {
|
2021-12-21 23:37:30 +00:00
|
|
|
b.f.d.e.a.n(f.class, e, "Failed to write to disk-cache for key %s", cacheKey.b());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void c(CacheKey cacheKey) {
|
|
|
|
d dVar = (d) this.a;
|
|
|
|
Objects.requireNonNull(dVar);
|
|
|
|
try {
|
|
|
|
synchronized (dVar.q) {
|
2021-12-21 23:37:30 +00:00
|
|
|
List<String> y0 = b.c.a.a0.d.y0(cacheKey);
|
2021-06-27 20:44:35 +00:00
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
2021-11-08 18:25:28 +00:00
|
|
|
ArrayList arrayList = (ArrayList) y0;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (i < arrayList.size()) {
|
|
|
|
String str = (String) arrayList.get(i);
|
|
|
|
if (dVar.k.c(str, cacheKey)) {
|
|
|
|
dVar.h.add(str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException unused) {
|
|
|
|
i a2 = i.a();
|
|
|
|
a2.d = cacheKey;
|
2021-12-21 23:37:30 +00:00
|
|
|
Objects.requireNonNull((b.f.b.a.e) dVar.g);
|
2021-06-27 20:44:35 +00:00
|
|
|
a2.b();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
/* JADX DEBUG: Type inference failed for r1v9. Raw type applied. Possible types: z.g<java.lang.Boolean>, z.g<b.f.j.j.e> */
|
|
|
|
/* JADX DEBUG: Type inference failed for r1v10. Raw type applied. Possible types: z.g<java.lang.Boolean>, z.g<b.f.j.j.e> */
|
2021-11-08 18:25:28 +00:00
|
|
|
public final z.g<e> d(CacheKey cacheKey, e eVar) {
|
2021-06-27 20:44:35 +00:00
|
|
|
cacheKey.b();
|
2021-12-21 23:37:30 +00:00
|
|
|
int i = b.f.d.e.a.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
Objects.requireNonNull((z) this.g);
|
2021-11-08 18:25:28 +00:00
|
|
|
Executor executor = z.g.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (eVar instanceof Boolean) {
|
2021-12-21 23:37:30 +00:00
|
|
|
return ((Boolean) eVar).booleanValue() ? z.g.c : z.g.d;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-11-08 18:25:28 +00:00
|
|
|
z.g<e> gVar = new z.g<>();
|
2021-06-27 20:44:35 +00:00
|
|
|
if (gVar.h(eVar)) {
|
|
|
|
return gVar;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("Cannot set the result of a completed task.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: finally extract failed */
|
2021-11-08 18:25:28 +00:00
|
|
|
public z.g<e> e(CacheKey cacheKey, AtomicBoolean atomicBoolean) {
|
|
|
|
z.g<e> gVar;
|
2021-06-27 20:44:35 +00:00
|
|
|
try {
|
|
|
|
b.b();
|
|
|
|
e a2 = this.f.a(cacheKey);
|
|
|
|
if (a2 != null) {
|
2021-11-08 18:25:28 +00:00
|
|
|
z.g<e> d = d(cacheKey, a2);
|
2021-06-27 20:44:35 +00:00
|
|
|
b.b();
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
try {
|
2021-11-08 18:25:28 +00:00
|
|
|
gVar = z.g.a(new e(this, null, atomicBoolean, cacheKey), this.d);
|
2021-06-27 20:44:35 +00:00
|
|
|
} catch (Exception e) {
|
2021-12-21 23:37:30 +00:00
|
|
|
b.f.d.e.a.n(f.class, e, "Failed to schedule disk-cache read for %s", ((b.f.b.a.f) cacheKey).a);
|
2021-11-08 18:25:28 +00:00
|
|
|
gVar = z.g.c(e);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
b.b();
|
|
|
|
return gVar;
|
|
|
|
} catch (Throwable th) {
|
|
|
|
b.b();
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: finally extract failed */
|
|
|
|
public void f(CacheKey cacheKey, e eVar) {
|
|
|
|
try {
|
|
|
|
b.b();
|
|
|
|
Objects.requireNonNull(cacheKey);
|
2021-12-21 23:37:30 +00:00
|
|
|
b.c.a.a0.d.i(Boolean.valueOf(e.t(eVar)));
|
2021-06-27 20:44:35 +00:00
|
|
|
this.f.b(cacheKey, eVar);
|
|
|
|
e a2 = e.a(eVar);
|
|
|
|
try {
|
|
|
|
this.e.execute(new a(null, cacheKey, a2));
|
|
|
|
} catch (Exception e) {
|
2021-12-21 23:37:30 +00:00
|
|
|
b.f.d.e.a.n(f.class, e, "Failed to schedule disk-cache write for %s", cacheKey.b());
|
2021-06-27 20:44:35 +00:00
|
|
|
this.f.d(cacheKey, eVar);
|
|
|
|
if (a2 != null) {
|
|
|
|
a2.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b.b();
|
|
|
|
} catch (Throwable th) {
|
|
|
|
b.b();
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|