discord-jadx/app/src/main/java/b/f/j/c/f.java

194 lines
5.9 KiB
Java
Raw Normal View History

2021-12-17 21:59:34 +00:00
package b.f.j.c;
2021-07-24 02:37:17 +00:00
2021-12-17 21:59:34 +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-07-24 02:37:17 +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;
2022-01-13 08:07:50 +00:00
import java.util.concurrent.ExecutorService;
2021-07-24 02:37:17 +00:00
import java.util.concurrent.atomic.AtomicBoolean;
2022-03-07 09:34:54 +00:00
/* compiled from: BufferedDiskCache.java */
2022-04-04 09:20:14 +00:00
/* loaded from: classes2.dex */
2021-07-24 02:37:17 +00:00
public class f {
public final h a;
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-03-28 08:10:50 +00:00
public final g f554b;
2021-12-17 21:59:34 +00:00
public final j c;
2021-07-24 02:37:17 +00:00
public final Executor d;
public final Executor e;
public final a0 f = new a0();
public final r g;
2022-03-07 09:34:54 +00:00
/* compiled from: BufferedDiskCache.java */
2022-04-04 09:20:14 +00:00
/* loaded from: classes2.dex */
2021-07-24 02:37:17 +00:00
public class a implements Runnable {
2021-12-02 18:53:44 +00:00
public final /* synthetic */ CacheKey j;
public final /* synthetic */ e k;
2021-07-24 02:37:17 +00:00
public a(Object obj, CacheKey cacheKey, e eVar) {
2021-12-02 18:53:44 +00:00
this.j = cacheKey;
this.k = eVar;
2021-07-24 02:37:17 +00:00
}
@Override // java.lang.Runnable
public void run() {
2022-03-07 09:34:54 +00:00
try {
f.b(f.this, this.j, this.k);
} catch (Throwable th) {
try {
throw th;
} finally {
f.this.f.d(this.j, this.k);
e eVar = this.k;
if (eVar != null) {
eVar.close();
}
}
2021-07-24 02:37:17 +00:00
}
}
}
public f(h hVar, g gVar, j jVar, Executor executor, Executor executor2, r rVar) {
this.a = hVar;
2022-03-28 08:10:50 +00:00
this.f554b = gVar;
2021-12-17 21:59:34 +00:00
this.c = jVar;
2021-07-24 02:37:17 +00:00
this.d = executor;
this.e = executor2;
this.g = rVar;
}
public static PooledByteBuffer a(f fVar, CacheKey cacheKey) throws IOException {
Objects.requireNonNull(fVar);
try {
cacheKey.b();
2021-12-17 21:59:34 +00:00
int i = b.f.d.e.a.a;
b.f.a.a b2 = ((d) fVar.a).b(cacheKey);
if (b2 == null) {
2021-07-24 02:37:17 +00:00
cacheKey.b();
Objects.requireNonNull((z) fVar.g);
return null;
}
cacheKey.b();
Objects.requireNonNull((z) fVar.g);
2021-12-17 21:59:34 +00:00
FileInputStream fileInputStream = new FileInputStream(b2.a);
2022-03-28 08:10:50 +00:00
PooledByteBuffer d = fVar.f554b.d(fileInputStream, (int) b2.a());
2022-03-07 09:34:54 +00:00
fileInputStream.close();
cacheKey.b();
return d;
2021-07-24 02:37:17 +00:00
} catch (IOException e) {
2021-12-17 21:59:34 +00:00
b.f.d.e.a.n(f.class, e, "Exception reading from cache for %s", cacheKey.b());
2021-07-24 02:37:17 +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-17 21:59:34 +00:00
int i = b.f.d.e.a.a;
2021-07-24 02:37:17 +00:00
try {
((d) fVar.a).d(cacheKey, new h(fVar, eVar));
Objects.requireNonNull((z) fVar.g);
cacheKey.b();
} catch (IOException e) {
2021-12-17 21:59:34 +00:00
b.f.d.e.a.n(f.class, e, "Failed to write to disk-cache for key %s", cacheKey.b());
2021-07-24 02:37:17 +00:00
}
}
public void c(CacheKey cacheKey) {
d dVar = (d) this.a;
Objects.requireNonNull(dVar);
try {
synchronized (dVar.q) {
2022-01-13 08:07:50 +00:00
List<String> z0 = b.c.a.a0.d.z0(cacheKey);
2021-07-24 02:37:17 +00:00
int i = 0;
while (true) {
2022-01-13 08:07:50 +00:00
ArrayList arrayList = (ArrayList) z0;
2021-07-24 02:37:17 +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-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.e) dVar.g);
2021-07-24 02:37:17 +00:00
a2.b();
}
}
2021-11-02 06:38:17 +00:00
public final z.g<e> d(CacheKey cacheKey, e eVar) {
2021-07-24 02:37:17 +00:00
cacheKey.b();
2021-12-17 21:59:34 +00:00
int i = b.f.d.e.a.a;
2021-07-24 02:37:17 +00:00
Objects.requireNonNull((z) this.g);
2022-01-13 08:07:50 +00:00
ExecutorService executorService = z.g.a;
2021-07-24 02:37:17 +00:00
if (eVar instanceof Boolean) {
2022-01-13 08:07:50 +00:00
return ((Boolean) eVar).booleanValue() ? z.g.e : z.g.f;
2021-07-24 02:37:17 +00:00
}
2021-11-02 06:38:17 +00:00
z.g<e> gVar = new z.g<>();
2021-07-24 02:37:17 +00:00
if (gVar.h(eVar)) {
return gVar;
}
throw new IllegalStateException("Cannot set the result of a completed task.");
}
2021-11-02 06:38:17 +00:00
public z.g<e> e(CacheKey cacheKey, AtomicBoolean atomicBoolean) {
z.g<e> gVar;
2021-07-24 02:37:17 +00:00
try {
b.b();
e a2 = this.f.a(cacheKey);
if (a2 != null) {
2022-03-07 09:34:54 +00:00
return d(cacheKey, a2);
2021-07-24 02:37:17 +00:00
}
try {
2021-11-02 06:38:17 +00:00
gVar = z.g.a(new e(this, null, atomicBoolean, cacheKey), this.d);
2021-07-24 02:37:17 +00:00
} catch (Exception e) {
2021-12-17 21:59:34 +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-02 06:38:17 +00:00
gVar = z.g.c(e);
2021-07-24 02:37:17 +00:00
}
return gVar;
2022-03-07 09:34:54 +00:00
} finally {
2021-07-24 02:37:17 +00:00
b.b();
}
}
public void f(CacheKey cacheKey, e eVar) {
try {
b.b();
Objects.requireNonNull(cacheKey);
2022-01-13 08:07:50 +00:00
b.c.a.a0.d.i(Boolean.valueOf(e.u(eVar)));
2021-07-24 02:37:17 +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-17 21:59:34 +00:00
b.f.d.e.a.n(f.class, e, "Failed to schedule disk-cache write for %s", cacheKey.b());
2021-07-24 02:37:17 +00:00
this.f.d(cacheKey, eVar);
if (a2 != null) {
a2.close();
}
}
2022-03-07 09:34:54 +00:00
} finally {
2021-07-24 02:37:17 +00:00
b.b();
}
}
}