discord-jadx/app/src/main/java/b/f/b/b/a.java

424 lines
13 KiB
Java
Raw Normal View History

2021-12-17 21:59:34 +00:00
package b.f.b.b;
2021-07-24 02:37:17 +00:00
import android.os.Environment;
import androidx.annotation.VisibleForTesting;
2021-12-17 21:59:34 +00:00
import b.f.b.b.c;
import b.f.j.c.h;
2021-07-24 02:37:17 +00:00
import com.facebook.common.file.FileUtils$CreateDirectoryException;
import com.facebook.common.file.FileUtils$ParentDirNotFoundException;
import com.facebook.common.file.FileUtils$RenameException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
2022-01-13 08:07:50 +00:00
import java.io.InputStream;
2021-07-24 02:37:17 +00:00
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/* compiled from: DefaultDiskStorage */
public class a implements c {
public static final long a = TimeUnit.MINUTES.toMillis(30);
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-01-27 07:52:47 +00:00
public static final /* synthetic */ int f454b = 0;
2021-12-17 21:59:34 +00:00
public final File c;
2021-07-24 02:37:17 +00:00
public final boolean d;
public final File e;
2021-12-17 21:59:34 +00:00
public final b.f.b.a.a f;
public final b.f.d.k.a g;
2021-07-24 02:37:17 +00:00
/* compiled from: DefaultDiskStorage */
2021-12-17 21:59:34 +00:00
public class b implements b.f.d.c.a {
2021-07-24 02:37:17 +00:00
public final List<c.a> a = new ArrayList();
2022-02-02 08:50:56 +00:00
public b(C0057a aVar) {
2021-07-24 02:37:17 +00:00
}
2021-12-17 21:59:34 +00:00
@Override // b.f.d.c.a
2021-07-24 02:37:17 +00:00
public void a(File file) {
d h = a.h(a.this, file);
if (h != null && h.a == ".cnt") {
2022-01-27 07:52:47 +00:00
this.a.add(new c(h.f457b, file, null));
2021-07-24 02:37:17 +00:00
}
}
2021-12-17 21:59:34 +00:00
@Override // b.f.d.c.a
2021-07-24 02:37:17 +00:00
public void b(File file) {
}
2021-12-17 21:59:34 +00:00
@Override // b.f.d.c.a
2021-07-24 02:37:17 +00:00
public void c(File file) {
}
}
/* compiled from: DefaultDiskStorage */
@VisibleForTesting
public static class c implements c.a {
public final String a;
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-01-27 07:52:47 +00:00
public final b.f.a.a f456b;
2021-12-17 21:59:34 +00:00
public long c = -1;
2021-07-24 02:37:17 +00:00
public long d = -1;
2022-02-02 08:50:56 +00:00
public c(String str, File file, C0057a aVar) {
2021-07-24 02:37:17 +00:00
Objects.requireNonNull(str);
this.a = str;
2022-01-27 07:52:47 +00:00
this.f456b = new b.f.a.a(file);
2021-07-24 02:37:17 +00:00
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c.a
2021-07-24 02:37:17 +00:00
public long a() {
if (this.d < 0) {
2022-01-27 07:52:47 +00:00
this.d = this.f456b.a.lastModified();
2021-07-24 02:37:17 +00:00
}
return this.d;
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c.a
2021-07-24 02:37:17 +00:00
public String getId() {
return this.a;
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c.a
2021-07-24 02:37:17 +00:00
public long getSize() {
2021-12-17 21:59:34 +00:00
if (this.c < 0) {
2022-01-27 07:52:47 +00:00
this.c = this.f456b.a();
2021-07-24 02:37:17 +00:00
}
2021-12-17 21:59:34 +00:00
return this.c;
2021-07-24 02:37:17 +00:00
}
}
/* compiled from: DefaultDiskStorage */
public static class d {
public final String a;
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-01-27 07:52:47 +00:00
public final String f457b;
2021-07-24 02:37:17 +00:00
public d(String str, String str2) {
this.a = str;
2022-01-27 07:52:47 +00:00
this.f457b = str2;
2021-07-24 02:37:17 +00:00
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.a);
sb.append("(");
2022-01-27 07:52:47 +00:00
return b.d.b.a.a.H(sb, this.f457b, ")");
2021-07-24 02:37:17 +00:00
}
}
/* compiled from: DefaultDiskStorage */
public static class e extends IOException {
public e(long j, long j2) {
2021-11-05 06:48:17 +00:00
super("File was not written completely. Expected: " + j + ", found: " + j2);
2021-07-24 02:37:17 +00:00
}
}
/* compiled from: DefaultDiskStorage */
@VisibleForTesting
public class f implements c.b {
public final String a;
@VisibleForTesting
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-01-27 07:52:47 +00:00
public final File f458b;
2021-07-24 02:37:17 +00:00
public f(String str, File file) {
this.a = str;
2022-01-27 07:52:47 +00:00
this.f458b = file;
2021-07-24 02:37:17 +00:00
}
public boolean a() {
2022-01-27 07:52:47 +00:00
return !this.f458b.exists() || this.f458b.delete();
2021-07-24 02:37:17 +00:00
}
2021-12-17 21:59:34 +00:00
public b.f.a.a b(Object obj) throws IOException {
Objects.requireNonNull((b.f.d.k.c) a.this.g);
2021-07-24 02:37:17 +00:00
long currentTimeMillis = System.currentTimeMillis();
File j = a.this.j(this.a);
try {
2022-01-27 07:52:47 +00:00
b.c.a.a0.d.Q1(this.f458b, j);
2021-07-24 02:37:17 +00:00
if (j.exists()) {
j.setLastModified(currentTimeMillis);
}
2021-12-17 21:59:34 +00:00
return new b.f.a.a(j);
2021-07-24 02:37:17 +00:00
} catch (FileUtils$RenameException e) {
Throwable cause = e.getCause();
if (cause != null && !(cause instanceof FileUtils$ParentDirNotFoundException)) {
boolean z2 = cause instanceof FileNotFoundException;
}
2021-12-17 21:59:34 +00:00
b.f.b.a.a aVar = a.this.f;
2022-01-27 07:52:47 +00:00
int i = a.f454b;
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) aVar);
2021-07-24 02:37:17 +00:00
throw e;
}
}
/* JADX INFO: finally extract failed */
2021-12-17 21:59:34 +00:00
public void c(b.f.b.a.g gVar, Object obj) throws IOException {
2021-07-24 02:37:17 +00:00
try {
2022-01-27 07:52:47 +00:00
FileOutputStream fileOutputStream = new FileOutputStream(this.f458b);
2021-07-24 02:37:17 +00:00
try {
2021-12-17 21:59:34 +00:00
b.f.d.d.b bVar = new b.f.d.d.b(fileOutputStream);
2021-07-24 02:37:17 +00:00
h hVar = (h) gVar;
2022-01-13 08:07:50 +00:00
InputStream e = hVar.a.e();
Objects.requireNonNull(e);
2022-01-27 07:52:47 +00:00
hVar.f553b.c.a(e, bVar);
2021-07-24 02:37:17 +00:00
bVar.flush();
2021-12-02 18:53:44 +00:00
long j = bVar.j;
2021-07-24 02:37:17 +00:00
fileOutputStream.close();
2022-01-27 07:52:47 +00:00
if (this.f458b.length() != j) {
throw new e(j, this.f458b.length());
2021-07-24 02:37:17 +00:00
}
} catch (Throwable th) {
fileOutputStream.close();
throw th;
}
2022-01-13 08:07:50 +00:00
} catch (FileNotFoundException e2) {
2021-12-17 21:59:34 +00:00
b.f.b.a.a aVar = a.this.f;
2022-01-27 07:52:47 +00:00
int i = a.f454b;
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) aVar);
2022-01-13 08:07:50 +00:00
throw e2;
2021-07-24 02:37:17 +00:00
}
}
}
/* compiled from: DefaultDiskStorage */
2021-12-17 21:59:34 +00:00
public class g implements b.f.d.c.a {
2021-07-24 02:37:17 +00:00
public boolean a;
2022-02-02 08:50:56 +00:00
public g(C0057a aVar) {
2021-07-24 02:37:17 +00:00
}
/* JADX WARNING: Code restructure failed: missing block: B:7:0x002b, code lost:
2021-12-17 21:59:34 +00:00
if (r3 > (java.lang.System.currentTimeMillis() - b.f.b.b.a.a)) goto L_0x0036;
2021-07-24 02:37:17 +00:00
*/
2021-12-17 21:59:34 +00:00
@Override // b.f.d.c.a
2021-07-24 02:37:17 +00:00
public void a(File file) {
if (this.a) {
d h = a.h(a.this, file);
boolean z2 = false;
if (h != null) {
String str = h.a;
if (str == ".tmp") {
long lastModified = file.lastModified();
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.d.k.c) a.this.g);
2021-07-24 02:37:17 +00:00
} else {
if (str == ".cnt") {
z2 = true;
}
2021-12-17 21:59:34 +00:00
b.c.a.a0.d.B(z2);
2021-07-24 02:37:17 +00:00
}
z2 = true;
}
if (z2) {
return;
}
}
file.delete();
}
2021-12-17 21:59:34 +00:00
@Override // b.f.d.c.a
2021-07-24 02:37:17 +00:00
public void b(File file) {
if (!this.a && file.equals(a.this.e)) {
this.a = true;
}
}
2021-12-17 21:59:34 +00:00
@Override // b.f.d.c.a
2021-07-24 02:37:17 +00:00
public void c(File file) {
2021-12-17 21:59:34 +00:00
if (!a.this.c.equals(file) && !this.a) {
2021-07-24 02:37:17 +00:00
file.delete();
}
if (this.a && file.equals(a.this.e)) {
this.a = false;
}
}
}
/* JADX WARNING: Removed duplicated region for block: B:14:0x005b */
/* JADX WARNING: Removed duplicated region for block: B:19:0x0069 A[SYNTHETIC, Splitter:B:19:0x0069] */
2021-12-17 21:59:34 +00:00
public a(File file, int i, b.f.b.a.a aVar) {
2021-07-24 02:37:17 +00:00
boolean z2;
2021-12-17 21:59:34 +00:00
this.c = file;
2021-07-24 02:37:17 +00:00
boolean z3 = false;
try {
File externalStorageDirectory = Environment.getExternalStorageDirectory();
if (externalStorageDirectory != null) {
try {
z2 = file.getCanonicalPath().contains(externalStorageDirectory.toString());
} catch (IOException unused) {
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) aVar);
2021-07-24 02:37:17 +00:00
}
this.d = z2;
2021-12-17 21:59:34 +00:00
File file2 = new File(this.c, String.format(null, "%s.ols%d.%d", "v2", 100, Integer.valueOf(i)));
2021-07-24 02:37:17 +00:00
this.e = file2;
this.f = aVar;
2021-12-17 21:59:34 +00:00
if (this.c.exists()) {
2021-07-24 02:37:17 +00:00
if (!file2.exists()) {
2022-01-13 08:07:50 +00:00
b.c.a.a0.d.Z(this.c);
2021-07-24 02:37:17 +00:00
}
if (z3) {
try {
2022-01-13 08:07:50 +00:00
b.c.a.a0.d.l1(file2);
2021-07-24 02:37:17 +00:00
} catch (FileUtils$CreateDirectoryException unused2) {
2021-12-17 21:59:34 +00:00
b.f.b.a.a aVar2 = this.f;
StringBuilder R = b.d.b.a.a.R("version directory could not be created: ");
2021-11-05 06:48:17 +00:00
R.append(this.e);
R.toString();
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) aVar2);
2021-07-24 02:37:17 +00:00
}
}
2021-12-17 21:59:34 +00:00
this.g = b.f.d.k.c.a;
2021-07-24 02:37:17 +00:00
}
z3 = true;
if (z3) {
}
2021-12-17 21:59:34 +00:00
this.g = b.f.d.k.c.a;
2021-07-24 02:37:17 +00:00
}
} catch (Exception unused3) {
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) aVar);
2021-07-24 02:37:17 +00:00
}
z2 = false;
this.d = z2;
2021-12-17 21:59:34 +00:00
File file2 = new File(this.c, String.format(null, "%s.ols%d.%d", "v2", 100, Integer.valueOf(i)));
2021-07-24 02:37:17 +00:00
this.e = file2;
this.f = aVar;
2021-12-17 21:59:34 +00:00
if (this.c.exists()) {
2021-07-24 02:37:17 +00:00
}
z3 = true;
if (z3) {
}
2021-12-17 21:59:34 +00:00
this.g = b.f.d.k.c.a;
2021-07-24 02:37:17 +00:00
}
public static d h(a aVar, File file) {
d dVar;
Objects.requireNonNull(aVar);
String name = file.getName();
int lastIndexOf = name.lastIndexOf(46);
if (lastIndexOf > 0) {
String substring = name.substring(lastIndexOf);
String str = ".cnt";
if (!str.equals(substring)) {
str = ".tmp".equals(substring) ? ".tmp" : null;
}
if (str != null) {
String substring2 = name.substring(0, lastIndexOf);
if (str.equals(".tmp")) {
int lastIndexOf2 = substring2.lastIndexOf(46);
if (lastIndexOf2 > 0) {
substring2 = substring2.substring(0, lastIndexOf2);
}
}
dVar = new d(str, substring2);
2022-01-27 07:52:47 +00:00
if (dVar == null && new File(aVar.k(dVar.f457b)).equals(file.getParentFile())) {
2021-07-24 02:37:17 +00:00
return dVar;
}
return null;
}
}
dVar = null;
if (dVar == null) {
return null;
}
return dVar;
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public void a() {
2022-01-13 08:07:50 +00:00
b.c.a.a0.d.o2(this.c, new g(null));
2021-07-24 02:37:17 +00:00
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public c.b b(String str, Object obj) throws IOException {
File file = new File(k(str));
if (!file.exists()) {
try {
2022-01-13 08:07:50 +00:00
b.c.a.a0.d.l1(file);
2021-07-24 02:37:17 +00:00
} catch (FileUtils$CreateDirectoryException e2) {
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) this.f);
2021-07-24 02:37:17 +00:00
throw e2;
}
}
try {
return new f(str, File.createTempFile(str + ".", ".tmp", file));
} catch (IOException e3) {
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.b.a.d) this.f);
2021-07-24 02:37:17 +00:00
throw e3;
}
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public boolean c(String str, Object obj) {
File j = j(str);
boolean exists = j.exists();
if (exists) {
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.d.k.c) this.g);
2021-07-24 02:37:17 +00:00
j.setLastModified(System.currentTimeMillis());
}
return exists;
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
public b.f.a.a d(String str, Object obj) {
2021-07-24 02:37:17 +00:00
File j = j(str);
if (!j.exists()) {
return null;
}
2021-12-17 21:59:34 +00:00
Objects.requireNonNull((b.f.d.k.c) this.g);
2021-07-24 02:37:17 +00:00
j.setLastModified(System.currentTimeMillis());
2021-12-17 21:59:34 +00:00
return new b.f.a.a(j);
2021-07-24 02:37:17 +00:00
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public Collection e() throws IOException {
b bVar = new b(null);
2022-01-13 08:07:50 +00:00
b.c.a.a0.d.o2(this.e, bVar);
2021-07-24 02:37:17 +00:00
return Collections.unmodifiableList(bVar.a);
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public long f(String str) {
return i(j(str));
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public long g(c.a aVar) {
2022-01-27 07:52:47 +00:00
return i(((c) aVar).f456b.a);
2021-07-24 02:37:17 +00:00
}
public final long i(File file) {
if (!file.exists()) {
return 0;
}
long length = file.length();
if (file.delete()) {
return length;
}
return -1;
}
2021-12-17 21:59:34 +00:00
@Override // b.f.b.b.c
2021-07-24 02:37:17 +00:00
public boolean isExternal() {
return this.d;
}
@VisibleForTesting
public File j(String str) {
2022-01-13 08:07:50 +00:00
return new File(b.d.b.a.a.J(b.d.b.a.a.R(k(str)), File.separator, str, ".cnt"));
2021-07-24 02:37:17 +00:00
}
public final String k(String str) {
String valueOf = String.valueOf(Math.abs(str.hashCode() % 100));
StringBuilder sb = new StringBuilder();
sb.append(this.e);
2021-12-17 21:59:34 +00:00
return b.d.b.a.a.H(sb, File.separator, valueOf);
2021-07-24 02:37:17 +00:00
}
}