Merge remote-tracking branch 'FabricMC/dev/0.6' into dev/0.6-forge

# Conflicts:
#	build.gradle
This commit is contained in:
shedaniel
2022-07-03 17:50:40 +08:00
2 changed files with 18 additions and 2 deletions

View File

@@ -26,9 +26,11 @@ package net.fabricmc.loom.util;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
@@ -109,7 +111,13 @@ public class DownloadUtil {
}
try { // Try download to the output
FileUtils.copyInputStreamToFile(connection.getInputStream(), to);
InputStream inputStream = connection.getInputStream();
if ("gzip".equals(connection.getContentEncoding())) {
inputStream = new GZIPInputStream(inputStream);
}
FileUtils.copyInputStreamToFile(inputStream, to);
} catch (IOException e) {
to.delete(); // Probably isn't good if it fails to copy/save
throw e;

View File

@@ -26,9 +26,11 @@ package net.fabricmc.loom.util;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
import javax.annotation.Nullable;
@@ -99,7 +101,13 @@ public class HashedDownloadUtil {
}
try { // Try download to the output
FileUtils.copyInputStreamToFile(connection.getInputStream(), to);
InputStream inputStream = connection.getInputStream();
if ("gzip".equals(connection.getContentEncoding())) {
inputStream = new GZIPInputStream(inputStream);
}
FileUtils.copyInputStreamToFile(inputStream, to);
} catch (IOException e) {
delete(to); // Probably isn't good if it fails to copy/save
throw e;