Skip to content

Commit

Permalink
release: 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 committed Jan 26, 2025
1 parent 28fa4f2 commit 2718236
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
}
Expand Down Expand Up @@ -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))) {
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 2718236

Please sign in to comment.