package com.google.android.play.core.assetpacks; import java.io.File; import java.io.IOException; /* loaded from: classes2.dex */ final class i2 { /* renamed from: b, reason: collision with root package name */ private static final r3.h0 f4921b = new r3.h0("MergeSliceTaskHandler"); /* renamed from: a, reason: collision with root package name */ private final e0 f4922a; i2(e0 e0Var) { this.f4922a = e0Var; } private static void b(File file, File file2) { if (!file.isDirectory()) { if (file2.exists()) { throw new d1("File clashing with existing file from other slice: ".concat(file2.toString())); } if (!file.renameTo(file2)) { throw new d1("Unable to move file: ".concat(String.valueOf(file))); } return; } file2.mkdirs(); for (File file3 : file.listFiles()) { b(file3, new File(file2, file3.getName())); } if (!file.delete()) { throw new d1("Unable to delete directory: ".concat(String.valueOf(file))); } } public final void a(h2 h2Var) { File C = this.f4922a.C(h2Var.f5165b, h2Var.f4908c, h2Var.f4909d, h2Var.f4910e); if (!C.exists()) { throw new d1(String.format("Cannot find verified files for slice %s.", h2Var.f4910e), h2Var.f5164a); } File v10 = this.f4922a.v(h2Var.f5165b, h2Var.f4908c, h2Var.f4909d); if (!v10.exists()) { v10.mkdirs(); } b(C, v10); try { this.f4922a.a(h2Var.f5165b, h2Var.f4908c, h2Var.f4909d, this.f4922a.p(h2Var.f5165b, h2Var.f4908c, h2Var.f4909d) + 1); } catch (IOException e10) { f4921b.b("Writing merge checkpoint failed with %s.", e10.getMessage()); throw new d1("Writing merge checkpoint failed.", e10, h2Var.f5164a); } } }