Use the given manifest version hash if possible (#337)
parent
f7efac5d18
commit
ba3a1e4d9c
|
@ -31,8 +31,6 @@ import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.zip.ZipError;
|
import java.util.zip.ZipError;
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
@ -170,13 +168,11 @@ public class MinecraftProvider extends DependencyProvider {
|
||||||
} else {
|
} else {
|
||||||
getProject().getLogger().debug("Downloading Minecraft {} manifest", minecraftVersion);
|
getProject().getLogger().debug("Downloading Minecraft {} manifest", minecraftVersion);
|
||||||
|
|
||||||
String url = optionalVersion.get().url;
|
ManifestVersion.Versions version = optionalVersion.get();
|
||||||
// Find the sha1 of the json from the url, return true if it matches the local json
|
String url = version.url;
|
||||||
Pattern sha1Pattern = Pattern.compile("\\b[0-9a-f]{5,40}\\b");
|
|
||||||
Matcher matcher = sha1Pattern.matcher(url);
|
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (version.sha1 != null) {
|
||||||
HashedDownloadUtil.downloadIfInvalid(new URL(url), minecraftJson, matcher.group(), getProject().getLogger(), true);
|
HashedDownloadUtil.downloadIfInvalid(new URL(url), minecraftJson, version.sha1, getProject().getLogger(), true);
|
||||||
} else {
|
} else {
|
||||||
// Use the etag if no hash found from url
|
// Use the etag if no hash found from url
|
||||||
DownloadUtil.downloadIfChanged(new URL(url), minecraftJson, getProject().getLogger());
|
DownloadUtil.downloadIfChanged(new URL(url), minecraftJson, getProject().getLogger());
|
||||||
|
|
|
@ -31,6 +31,6 @@ public class ManifestVersion {
|
||||||
public List<Versions> versions = new ArrayList<>();
|
public List<Versions> versions = new ArrayList<>();
|
||||||
|
|
||||||
public static class Versions {
|
public static class Versions {
|
||||||
public String id, url;
|
public String id, url, sha1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue