package okhttp3.internal.cache;

import S4.m;
import S4.p;
import android.support.v4.media.session.b;
import com.google.android.recaptcha.internal.a;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.Flushable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import kotlin.jvm.internal.o;
import okhttp3.internal.Util;
import okhttp3.internal.cache.DiskLruCache;
import okhttp3.internal.concurrent.Task;
import okhttp3.internal.concurrent.TaskQueue;
import okhttp3.internal.concurrent.TaskRunner;
import okhttp3.internal.io.FileSystem;
import okhttp3.internal.platform.Platform;
import p5.AbstractC2732b;
import p5.C2734d;
import p5.C2737g;
import p5.I;
import p5.J;
import p5.N;
import p5.P;
import p5.w;

/* JADX INFO: loaded from: classes3.dex */
public final class DiskLruCache implements Closeable, Flushable {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public static final long f22206A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public static final m f22207B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public static final String f22208C;

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    public static final String f22209D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public static final String f22210E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public static final String f22211F;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public static final String f22212v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public static final String f22213w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final String f22214x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final String f22215y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static final String f22216z;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final FileSystem f22217a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final File f22218b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final File f22219c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final File f22220d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final File f22221e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public long f22222f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public I f22223j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final LinkedHashMap f22224k;
    public int l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f22225m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f22226n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public boolean f22227o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public boolean f22228p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f22229q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public boolean f22230r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public long f22231s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final TaskQueue f22232t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final DiskLruCache$cleanupTask$1 f22233u;

    public static final class Companion {
        public /* synthetic */ Companion(int i6) {
            this();
        }

        private Companion() {
        }
    }

    public final class Editor {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final Entry f22234a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final boolean[] f22235b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public boolean f22236c;

        public Editor(Entry entry) {
            boolean[] zArr;
            this.f22234a = entry;
            if (entry.f22244e) {
                zArr = null;
            } else {
                DiskLruCache.this.getClass();
                zArr = new boolean[2];
            }
            this.f22235b = zArr;
        }

        public final void a() {
            DiskLruCache diskLruCache = DiskLruCache.this;
            synchronized (diskLruCache) {
                try {
                    if (this.f22236c) {
                        throw new IllegalStateException("Check failed.");
                    }
                    if (o.c(this.f22234a.f22246g, this)) {
                        diskLruCache.b(this, false);
                    }
                    this.f22236c = true;
                } catch (Throwable th) {
                    throw th;
                }
            }
        }

        public final void b() {
            DiskLruCache diskLruCache = DiskLruCache.this;
            synchronized (diskLruCache) {
                try {
                    if (this.f22236c) {
                        throw new IllegalStateException("Check failed.");
                    }
                    if (o.c(this.f22234a.f22246g, this)) {
                        diskLruCache.b(this, true);
                    }
                    this.f22236c = true;
                } catch (Throwable th) {
                    throw th;
                }
            }
        }

        public final void c() {
            Entry entry = this.f22234a;
            if (o.c(entry.f22246g, this)) {
                DiskLruCache diskLruCache = DiskLruCache.this;
                if (diskLruCache.f22226n) {
                    diskLruCache.b(this, false);
                } else {
                    entry.f22245f = true;
                }
            }
        }

        public final N d(int i6) {
            DiskLruCache diskLruCache = DiskLruCache.this;
            synchronized (diskLruCache) {
                try {
                    if (this.f22236c) {
                        throw new IllegalStateException("Check failed.");
                    }
                    if (!o.c(this.f22234a.f22246g, this)) {
                        return new C2737g();
                    }
                    if (!this.f22234a.f22244e) {
                        boolean[] zArr = this.f22235b;
                        o.e(zArr);
                        zArr[i6] = true;
                    }
                    try {
                        return new FaultHidingSink(diskLruCache.f22217a.b((File) this.f22234a.f22243d.get(i6)), new DiskLruCache$Editor$newSink$1$1(diskLruCache, this));
                    } catch (FileNotFoundException unused) {
                        return new C2737g();
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
    }

    public final class Entry {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final String f22240a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final long[] f22241b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public final ArrayList f22242c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public final ArrayList f22243d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public boolean f22244e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public boolean f22245f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public Editor f22246g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public int f22247h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public long f22248i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public final /* synthetic */ DiskLruCache f22249j;

        public Entry(DiskLruCache diskLruCache, String key) {
            o.h(key, "key");
            this.f22249j = diskLruCache;
            this.f22240a = key;
            diskLruCache.getClass();
            this.f22241b = new long[2];
            this.f22242c = new ArrayList();
            this.f22243d = new ArrayList();
            StringBuilder sb = new StringBuilder(key);
            sb.append('.');
            int length = sb.length();
            for (int i6 = 0; i6 < 2; i6++) {
                sb.append(i6);
                this.f22242c.add(new File(this.f22249j.f22218b, sb.toString()));
                sb.append(".tmp");
                this.f22243d.add(new File(this.f22249j.f22218b, sb.toString()));
                sb.setLength(length);
            }
        }

        public final Snapshot a() {
            byte[] bArr = Util.f22179a;
            if (!this.f22244e) {
                return null;
            }
            final DiskLruCache diskLruCache = this.f22249j;
            if (!diskLruCache.f22226n && (this.f22246g != null || this.f22245f)) {
                return null;
            }
            ArrayList arrayList = new ArrayList();
            long[] jArr = (long[]) this.f22241b.clone();
            for (int i6 = 0; i6 < 2; i6++) {
                try {
                    final P pA = diskLruCache.f22217a.a((File) this.f22242c.get(i6));
                    if (!diskLruCache.f22226n) {
                        this.f22247h++;
                        pA = new w(pA) { // from class: okhttp3.internal.cache.DiskLruCache$Entry$newSource$1

                            /* JADX INFO: renamed from: a, reason: collision with root package name */
                            public boolean f22250a;

                            @Override // p5.w, java.io.Closeable, java.lang.AutoCloseable
                            public final void close() {
                                super.close();
                                if (this.f22250a) {
                                    return;
                                }
                                this.f22250a = true;
                                DiskLruCache diskLruCache2 = diskLruCache;
                                DiskLruCache.Entry entry = this;
                                synchronized (diskLruCache2) {
                                    int i7 = entry.f22247h - 1;
                                    entry.f22247h = i7;
                                    if (i7 == 0 && entry.f22245f) {
                                        diskLruCache2.A(entry);
                                    }
                                }
                            }
                        };
                    }
                    arrayList.add(pA);
                } catch (FileNotFoundException unused) {
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        Util.c((P) it.next());
                    }
                    try {
                        diskLruCache.A(this);
                        return null;
                    } catch (IOException unused2) {
                        return null;
                    }
                }
            }
            return new Snapshot(this.f22249j, this.f22240a, this.f22248i, arrayList, jArr);
        }
    }

    public final class Snapshot implements Closeable {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final String f22253a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final long f22254b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public final ArrayList f22255c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public final /* synthetic */ DiskLruCache f22256d;

        public Snapshot(DiskLruCache diskLruCache, String key, long j4, ArrayList arrayList, long[] lengths) {
            o.h(key, "key");
            o.h(lengths, "lengths");
            this.f22256d = diskLruCache;
            this.f22253a = key;
            this.f22254b = j4;
            this.f22255c = arrayList;
        }

        @Override // java.io.Closeable, java.lang.AutoCloseable
        public final void close() {
            Iterator it = this.f22255c.iterator();
            while (it.hasNext()) {
                Util.c((P) it.next());
            }
        }
    }

    static {
        new Companion(0);
        f22212v = coil.disk.DiskLruCache.JOURNAL_FILE;
        f22213w = coil.disk.DiskLruCache.JOURNAL_FILE_TMP;
        f22214x = coil.disk.DiskLruCache.JOURNAL_FILE_BACKUP;
        f22215y = coil.disk.DiskLruCache.MAGIC;
        f22216z = "1";
        f22206A = -1L;
        f22207B = new m("[a-z0-9_-]{1,120}");
        f22208C = "CLEAN";
        f22209D = "DIRTY";
        f22210E = "REMOVE";
        f22211F = "READ";
    }

    /* JADX WARN: Type inference failed for: r6v2, types: [okhttp3.internal.cache.DiskLruCache$cleanupTask$1] */
    public DiskLruCache(FileSystem fileSystem, File file, TaskRunner taskRunner) {
        o.h(fileSystem, "fileSystem");
        o.h(taskRunner, "taskRunner");
        this.f22217a = fileSystem;
        this.f22218b = file;
        this.f22224k = new LinkedHashMap(0, 0.75f, true);
        this.f22232t = taskRunner.e();
        final String strN = a.n(new StringBuilder(), Util.f22185g, " Cache");
        this.f22233u = new Task(strN) { // from class: okhttp3.internal.cache.DiskLruCache$cleanupTask$1
            @Override // okhttp3.internal.concurrent.Task
            public final long a() {
                DiskLruCache diskLruCache = this.f22257e;
                synchronized (diskLruCache) {
                    if (!diskLruCache.f22227o || diskLruCache.f22228p) {
                        return -1L;
                    }
                    try {
                        diskLruCache.B();
                    } catch (IOException unused) {
                        diskLruCache.f22229q = true;
                    }
                    try {
                        if (diskLruCache.g()) {
                            diskLruCache.z();
                            diskLruCache.l = 0;
                        }
                    } catch (IOException unused2) {
                        diskLruCache.f22230r = true;
                        diskLruCache.f22223j = AbstractC2732b.b(new C2737g());
                    }
                    return -1L;
                }
            }
        };
        this.f22219c = new File(file, f22212v);
        this.f22220d = new File(file, f22213w);
        this.f22221e = new File(file, f22214x);
    }

    public static void C(String str) {
        if (!f22207B.d(str)) {
            throw new IllegalArgumentException(A0.a.k('\"', "keys must match regex [a-z0-9_-]{1,120}: \"", str).toString());
        }
    }

    public final void A(Entry entry) {
        I i6;
        o.h(entry, "entry");
        boolean z6 = this.f22226n;
        String str = entry.f22240a;
        if (!z6) {
            if (entry.f22247h > 0 && (i6 = this.f22223j) != null) {
                i6.n(f22209D);
                i6.h(32);
                i6.n(str);
                i6.h(10);
                i6.flush();
            }
            if (entry.f22247h > 0 || entry.f22246g != null) {
                entry.f22245f = true;
                return;
            }
        }
        Editor editor = entry.f22246g;
        if (editor != null) {
            editor.c();
        }
        for (int i7 = 0; i7 < 2; i7++) {
            this.f22217a.f((File) entry.f22242c.get(i7));
            long j4 = this.f22222f;
            long[] jArr = entry.f22241b;
            this.f22222f = j4 - jArr[i7];
            jArr[i7] = 0;
        }
        this.l++;
        I i8 = this.f22223j;
        if (i8 != null) {
            i8.n(f22210E);
            i8.h(32);
            i8.n(str);
            i8.h(10);
        }
        this.f22224k.remove(str);
        if (g()) {
            this.f22232t.c(this.f22233u, 0L);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:9:0x0023, code lost:
    
        A(r1);
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void B() {
        while (this.f22222f > 104857600) {
            for (Entry entry : this.f22224k.values()) {
                if (!entry.f22245f) {
                    break;
                }
            }
            return;
        }
        this.f22229q = false;
    }

    public final synchronized void a() {
        if (this.f22228p) {
            throw new IllegalStateException("cache is closed");
        }
    }

    public final synchronized void b(Editor editor, boolean z6) {
        o.h(editor, "editor");
        Entry entry = editor.f22234a;
        if (!o.c(entry.f22246g, editor)) {
            throw new IllegalStateException("Check failed.");
        }
        if (z6 && !entry.f22244e) {
            for (int i6 = 0; i6 < 2; i6++) {
                boolean[] zArr = editor.f22235b;
                o.e(zArr);
                if (!zArr[i6]) {
                    editor.a();
                    throw new IllegalStateException("Newly created entry didn't create value for index " + i6);
                }
                if (!this.f22217a.d((File) entry.f22243d.get(i6))) {
                    editor.a();
                    return;
                }
            }
        }
        for (int i7 = 0; i7 < 2; i7++) {
            File file = (File) entry.f22243d.get(i7);
            if (!z6 || entry.f22245f) {
                this.f22217a.f(file);
            } else if (this.f22217a.d(file)) {
                File file2 = (File) entry.f22242c.get(i7);
                this.f22217a.e(file, file2);
                long j4 = entry.f22241b[i7];
                long jH = this.f22217a.h(file2);
                entry.f22241b[i7] = jH;
                this.f22222f = (this.f22222f - j4) + jH;
            }
        }
        entry.f22246g = null;
        if (entry.f22245f) {
            A(entry);
            return;
        }
        this.l++;
        I i8 = this.f22223j;
        o.e(i8);
        if (entry.f22244e || z6) {
            entry.f22244e = true;
            i8.n(f22208C);
            i8.h(32);
            i8.n(entry.f22240a);
            for (long j6 : entry.f22241b) {
                i8.h(32);
                i8.w(j6);
            }
            i8.h(10);
            if (z6) {
                long j7 = this.f22231s;
                this.f22231s = 1 + j7;
                entry.f22248i = j7;
            }
        } else {
            this.f22224k.remove(entry.f22240a);
            i8.n(f22210E);
            i8.h(32);
            i8.n(entry.f22240a);
            i8.h(10);
        }
        i8.flush();
        if (this.f22222f > 104857600 || g()) {
            this.f22232t.c(this.f22233u, 0L);
        }
    }

    public final synchronized Editor c(String key, long j4) {
        try {
            o.h(key, "key");
            f();
            a();
            C(key);
            Entry entry = (Entry) this.f22224k.get(key);
            if (j4 != f22206A && (entry == null || entry.f22248i != j4)) {
                return null;
            }
            if ((entry != null ? entry.f22246g : null) != null) {
                return null;
            }
            if (entry != null && entry.f22247h != 0) {
                return null;
            }
            if (!this.f22229q && !this.f22230r) {
                I i6 = this.f22223j;
                o.e(i6);
                i6.n(f22209D);
                i6.h(32);
                i6.n(key);
                i6.h(10);
                i6.flush();
                if (this.f22225m) {
                    return null;
                }
                if (entry == null) {
                    entry = new Entry(this, key);
                    this.f22224k.put(key, entry);
                }
                Editor editor = new Editor(entry);
                entry.f22246g = editor;
                return editor;
            }
            this.f22232t.c(this.f22233u, 0L);
            return null;
        } catch (Throwable th) {
            throw th;
        }
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final synchronized void close() {
        try {
            if (this.f22227o && !this.f22228p) {
                Collection collectionValues = this.f22224k.values();
                o.g(collectionValues, "lruEntries.values");
                for (Entry entry : (Entry[]) collectionValues.toArray(new Entry[0])) {
                    Editor editor = entry.f22246g;
                    if (editor != null) {
                        editor.c();
                    }
                }
                B();
                I i6 = this.f22223j;
                o.e(i6);
                i6.close();
                this.f22223j = null;
                this.f22228p = true;
                return;
            }
            this.f22228p = true;
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized Snapshot d(String key) {
        o.h(key, "key");
        f();
        a();
        C(key);
        Entry entry = (Entry) this.f22224k.get(key);
        if (entry == null) {
            return null;
        }
        Snapshot snapshotA = entry.a();
        if (snapshotA == null) {
            return null;
        }
        this.l++;
        I i6 = this.f22223j;
        o.e(i6);
        i6.n(f22211F);
        i6.h(32);
        i6.n(key);
        i6.h(10);
        if (g()) {
            this.f22232t.c(this.f22233u, 0L);
        }
        return snapshotA;
    }

    public final synchronized void f() {
        boolean z6;
        try {
            byte[] bArr = Util.f22179a;
            if (this.f22227o) {
                return;
            }
            if (this.f22217a.d(this.f22221e)) {
                if (this.f22217a.d(this.f22219c)) {
                    this.f22217a.f(this.f22221e);
                } else {
                    this.f22217a.e(this.f22221e, this.f22219c);
                }
            }
            FileSystem fileSystem = this.f22217a;
            File file = this.f22221e;
            o.h(fileSystem, "<this>");
            o.h(file, "file");
            C2734d c2734dB = fileSystem.b(file);
            try {
                fileSystem.f(file);
                c2734dB.close();
                z6 = true;
            } catch (IOException unused) {
                c2734dB.close();
                fileSystem.f(file);
                z6 = false;
            } catch (Throwable th) {
                try {
                    throw th;
                } catch (Throwable th2) {
                    b.j(c2734dB, th);
                    throw th2;
                }
            }
            this.f22226n = z6;
            if (this.f22217a.d(this.f22219c)) {
                try {
                    t();
                    i();
                    this.f22227o = true;
                    return;
                } catch (IOException e6) {
                    Platform.Companion.get().log("DiskLruCache " + this.f22218b + " is corrupt: " + e6.getMessage() + ", removing", 5, e6);
                    try {
                        close();
                        this.f22217a.c(this.f22218b);
                        this.f22228p = false;
                        z();
                        this.f22227o = true;
                    } catch (Throwable th3) {
                        this.f22228p = false;
                        throw th3;
                    }
                }
            }
            z();
            this.f22227o = true;
        } catch (Throwable th4) {
            throw th4;
        }
    }

    @Override // java.io.Flushable
    public final synchronized void flush() {
        if (this.f22227o) {
            a();
            B();
            I i6 = this.f22223j;
            o.e(i6);
            i6.flush();
        }
    }

    public final boolean g() {
        int i6 = this.l;
        return i6 >= 2000 && i6 >= this.f22224k.size();
    }

    public final void i() {
        File file = this.f22220d;
        FileSystem fileSystem = this.f22217a;
        fileSystem.f(file);
        Iterator it = this.f22224k.values().iterator();
        while (it.hasNext()) {
            Object next = it.next();
            o.g(next, "i.next()");
            Entry entry = (Entry) next;
            int i6 = 0;
            if (entry.f22246g == null) {
                while (i6 < 2) {
                    this.f22222f += entry.f22241b[i6];
                    i6++;
                }
            } else {
                entry.f22246g = null;
                while (i6 < 2) {
                    fileSystem.f((File) entry.f22242c.get(i6));
                    fileSystem.f((File) entry.f22243d.get(i6));
                    i6++;
                }
                it.remove();
            }
        }
    }

    public final void t() throws IOException {
        File file = this.f22219c;
        FileSystem fileSystem = this.f22217a;
        J jC = AbstractC2732b.c(fileSystem.a(file));
        try {
            String strZ = jC.z(Long.MAX_VALUE);
            String strZ2 = jC.z(Long.MAX_VALUE);
            String strZ3 = jC.z(Long.MAX_VALUE);
            String strZ4 = jC.z(Long.MAX_VALUE);
            String strZ5 = jC.z(Long.MAX_VALUE);
            if (!o.c(f22215y, strZ) || !o.c(f22216z, strZ2) || !o.c(String.valueOf(201105), strZ3) || !o.c(String.valueOf(2), strZ4) || strZ5.length() > 0) {
                throw new IOException("unexpected journal header: [" + strZ + ", " + strZ2 + ", " + strZ4 + ", " + strZ5 + ']');
            }
            int i6 = 0;
            while (true) {
                try {
                    y(jC.z(Long.MAX_VALUE));
                    i6++;
                } catch (EOFException unused) {
                    this.l = i6 - this.f22224k.size();
                    if (jC.a()) {
                        this.f22223j = AbstractC2732b.b(new FaultHidingSink(fileSystem.g(file), new DiskLruCache$newJournalWriter$faultHidingSink$1(this)));
                    } else {
                        z();
                    }
                    jC.close();
                    return;
                }
            }
        } finally {
        }
    }

    public final void y(String str) throws IOException {
        String strSubstring;
        int iN0 = p.N0(str, ' ', 0, 6);
        if (iN0 == -1) {
            throw new IOException("unexpected journal line: ".concat(str));
        }
        int i6 = iN0 + 1;
        int iN02 = p.N0(str, ' ', i6, 4);
        LinkedHashMap linkedHashMap = this.f22224k;
        if (iN02 == -1) {
            strSubstring = str.substring(i6);
            o.g(strSubstring, "this as java.lang.String).substring(startIndex)");
            String str2 = f22210E;
            if (iN0 == str2.length() && S4.w.A0(str, str2, false)) {
                linkedHashMap.remove(strSubstring);
                return;
            }
        } else {
            strSubstring = str.substring(i6, iN02);
            o.g(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)");
        }
        Entry entry = (Entry) linkedHashMap.get(strSubstring);
        if (entry == null) {
            entry = new Entry(this, strSubstring);
            linkedHashMap.put(strSubstring, entry);
        }
        if (iN02 != -1) {
            String str3 = f22208C;
            if (iN0 == str3.length() && S4.w.A0(str, str3, false)) {
                String strSubstring2 = str.substring(iN02 + 1);
                o.g(strSubstring2, "this as java.lang.String).substring(startIndex)");
                List listC1 = p.c1(strSubstring2, new char[]{' '}, 6);
                entry.f22244e = true;
                entry.f22246g = null;
                int size = listC1.size();
                entry.f22249j.getClass();
                if (size != 2) {
                    throw new IOException("unexpected journal line: " + listC1);
                }
                try {
                    int size2 = listC1.size();
                    for (int i7 = 0; i7 < size2; i7++) {
                        entry.f22241b[i7] = Long.parseLong((String) listC1.get(i7));
                    }
                    return;
                } catch (NumberFormatException unused) {
                    throw new IOException("unexpected journal line: " + listC1);
                }
            }
        }
        if (iN02 == -1) {
            String str4 = f22209D;
            if (iN0 == str4.length() && S4.w.A0(str, str4, false)) {
                entry.f22246g = new Editor(entry);
                return;
            }
        }
        if (iN02 == -1) {
            String str5 = f22211F;
            if (iN0 == str5.length() && S4.w.A0(str, str5, false)) {
                return;
            }
        }
        throw new IOException("unexpected journal line: ".concat(str));
    }

    public final synchronized void z() {
        try {
            I i6 = this.f22223j;
            if (i6 != null) {
                i6.close();
            }
            I iB = AbstractC2732b.b(this.f22217a.b(this.f22220d));
            try {
                iB.n(f22215y);
                iB.h(10);
                iB.n(f22216z);
                iB.h(10);
                iB.w(201105);
                iB.h(10);
                iB.w(2);
                iB.h(10);
                iB.h(10);
                Iterator it = this.f22224k.values().iterator();
                while (true) {
                    if (!it.hasNext()) {
                        break;
                    }
                    Entry entry = (Entry) it.next();
                    if (entry.f22246g != null) {
                        iB.n(f22209D);
                        iB.h(32);
                        iB.n(entry.f22240a);
                        iB.h(10);
                    } else {
                        iB.n(f22208C);
                        iB.h(32);
                        iB.n(entry.f22240a);
                        for (long j4 : entry.f22241b) {
                            iB.h(32);
                            iB.w(j4);
                        }
                        iB.h(10);
                    }
                }
                iB.close();
                if (this.f22217a.d(this.f22219c)) {
                    this.f22217a.e(this.f22219c, this.f22221e);
                }
                this.f22217a.e(this.f22220d, this.f22219c);
                this.f22217a.f(this.f22221e);
                this.f22223j = AbstractC2732b.b(new FaultHidingSink(this.f22217a.g(this.f22219c), new DiskLruCache$newJournalWriter$faultHidingSink$1(this)));
                this.f22225m = false;
                this.f22230r = false;
            } finally {
            }
        } catch (Throwable th) {
            throw th;
        }
    }
}
