From 27182360cc7fc4037afd615c662ce5b7f9ac4c29 Mon Sep 17 00:00:00 2001 From: Izuna Date: Sun, 26 Jan 2025 15:31:42 +0100 Subject: [PATCH] release: 1.3.3 --- gradle.properties | 2 +- java-cef | 2 +- .../mcef/MCEFResourceManager.java | 57 +++++++++++++++++-- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index f86e0698..da78b682 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ yarn_mappings=1.21.4+build.2 loader_version=0.16.5 archives_base_name=mcef -mod_version=1.3.2-1.21.4 +mod_version=1.3.3-1.21.4 maven_group=CCBlueX loom_version=1.9-SNAPSHOT diff --git a/java-cef b/java-cef index 0e837c94..06399a49 160000 --- a/java-cef +++ b/java-cef @@ -1 +1 @@ -Subproject commit 0e837c94ea090b6eb4b9bc65428ec28fd75d1d72 +Subproject commit 06399a49d24f2c372668ccce26a15c533199ec9e diff --git a/src/main/java/net/ccbluex/liquidbounce/mcef/MCEFResourceManager.java b/src/main/java/net/ccbluex/liquidbounce/mcef/MCEFResourceManager.java index a9940101..bf457cfa 100644 --- a/src/main/java/net/ccbluex/liquidbounce/mcef/MCEFResourceManager.java +++ b/src/main/java/net/ccbluex/liquidbounce/mcef/MCEFResourceManager.java @@ -112,8 +112,25 @@ public void downloadJcef() throws IOException { while (true) { try { var tarGzArchive = new File(commitDirectory, platform.getNormalizedName() + ".tar.gz"); + var checksumFile = new File(commitDirectory, platform.getNormalizedName() + ".tar.gz.sha256"); + if (tarGzArchive.exists()) { - FileUtils.forceDelete(tarGzArchive); + try { + FileUtils.forceDelete(tarGzArchive); + } catch (Exception e) { + MCEF.INSTANCE.getLogger().warn("Failed to delete existing .tar.gz file", e); + } + } + + // Checksum file should have been created by [compareChecksum] call in [requiresDownload] + // However if not, we either attempt to download it again. + if (!checksumFile.exists()) { + try { + downloadFile(getJavaCefChecksumDownloadUrl(), checksumFile, progressTracker); + } catch (Exception e) { + MCEF.INSTANCE.getLogger().error("Failed to download checksum file", e); + throw e; + } } // Download JCEF from file hosting @@ -133,7 +150,6 @@ public void downloadJcef() throws IOException { // Compare checksum of .tar.gz file with remote checksum file progressTracker.setTask("Comparing Checksum"); - var checksumFile = new File(commitDirectory, platform.getNormalizedName() + ".tar.gz.sha256"); if (!compareChecksum(checksumFile, tarGzArchive)) { throw new IOException("Checksum mismatch"); } @@ -230,19 +246,36 @@ private boolean compareChecksum(File checksumFile, File archiveFile) { } } - private void downloadFile(String urlString, File outputFile, MCEFProgressTracker percentCompleteConsumer) throws IOException { - var client = new OkHttpClient(); + private void downloadFile(String urlString, File outputFile, MCEFProgressTracker percentCompleteConsumer) + throws IOException { + var client = new OkHttpClient.Builder() + .followRedirects(true) + .followSslRedirects(true) + .build(); + var request = new Request.Builder() .url(urlString) .build(); try (var response = client.newCall(request).execute()) { if (!response.isSuccessful()) { - throw new IOException("Unexpected response status: " + response.code()); + throw new IOException(String.format( + "Download Failed: %n" + + "URL: %s%n" + + "HTTP Status: %d %s%n" + + "Response Headers: %s%n" + + "Redirected: %s%n" + + "Final URL: %s", + urlString, + response.code(), + response.message(), + response.headers(), + response.priorResponse() != null, + response.request().url() + )); } var body = response.body(); - var contentLength = body.contentLength(); try (var source = body.source(); var sink = Okio.buffer(Okio.sink(outputFile))) { @@ -261,6 +294,18 @@ private void downloadFile(String urlString, File outputFile, MCEFProgressTracker } } } + } catch (IOException e) { + throw new IOException(String.format( + "Download Error:%n" + + "URL: %s%n" + + "Error Type: %s%n" + + "Error Message: %s%n" + + "Cause: %s", + urlString, + e.getClass().getName(), + e.getMessage(), + e.getCause() != null ? e.getCause().toString() : "None" + ), e); } }