mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Add a strict mode when download files, will be a bit slower but should help solve some issues.
This commit is contained in:
@@ -124,7 +124,7 @@ public class MinecraftAssetsProvider {
|
||||
progressLogger.progress(String.format("%-30.30s", assetName) + " - " + sha1);
|
||||
|
||||
try {
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file, sha1, project.getLogger(), true);
|
||||
HashedDownloadUtil.downloadIfInvalid(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file, sha1, project.getLogger(), true, false);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to download: " + assetName, e);
|
||||
}
|
||||
|
||||
@@ -41,16 +41,27 @@ import net.fabricmc.loom.LoomGradlePlugin;
|
||||
|
||||
public class HashedDownloadUtil {
|
||||
public static void downloadIfInvalid(URL from, File to, String expectedHash, Logger logger, boolean quiet) throws IOException {
|
||||
downloadIfInvalid(from, to, expectedHash, logger, quiet, true);
|
||||
}
|
||||
|
||||
public static void downloadIfInvalid(URL from, File to, String expectedHash, Logger logger, boolean quiet, boolean strict) throws IOException {
|
||||
if (LoomGradlePlugin.refreshDeps) {
|
||||
delete(to);
|
||||
}
|
||||
|
||||
if (to.exists()) {
|
||||
String sha1 = getSha1(to, logger);
|
||||
if (strict) {
|
||||
if (Checksum.equals(to, expectedHash)) {
|
||||
// The hash matches the target file
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
String sha1 = getSha1(to, logger);
|
||||
|
||||
if (expectedHash.equals(sha1)) {
|
||||
// The hash in the sha1 file matches
|
||||
return;
|
||||
if (expectedHash.equals(sha1)) {
|
||||
// The hash in the sha1 file matches
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +73,7 @@ public class HashedDownloadUtil {
|
||||
|
||||
if ((code < 200 || code > 299) && code != HttpURLConnection.HTTP_NOT_MODIFIED) {
|
||||
//Didn't get what we expected
|
||||
delete(to);
|
||||
throw new IOException(connection.getResponseMessage() + " for " + from);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user