Skip to content

Commit

Permalink
Don't verify checksums for yarn maven metadata at all
Browse files Browse the repository at this point in the history
This can't be reliably checked, as fabric's maven cache returns outdated files for a while after an update

Closes #10
  • Loading branch information
booky10 committed May 12, 2024
1 parent 79885d1 commit 30d4cc0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ protected MappingFormat getMappingFormat() {
return MappingFormat.TINY_2;
}

public VerifiableUrl.HashType getMetaHashType() {
return this.hashType;
}

public VerifiableUrl.HashType getJarHashType() {
return this.hashType;
}

@Override
protected CompletableFuture<Void> downloadMappings0(Path cacheDir, Executor executor) {
String version = getFabricatedVersion(this.versionData);
Expand All @@ -59,7 +67,7 @@ protected CompletableFuture<Void> downloadMappings0(Path cacheDir, Executor exec
return CompletableFuture.completedFuture(null);
}

return this.artifactInfo.buildVerifiableUrl(build, "jar", this.hashType, executor)
return this.artifactInfo.buildVerifiableUrl(build, "jar", this.getJarHashType(), executor)
.thenCompose(verifiableUrl -> {
LOGGER.info("Downloading {} mappings jar for build {}...", this.name, build);
return verifiableUrl.get(executor);
Expand Down Expand Up @@ -99,7 +107,7 @@ private CompletableFuture<String> fetchLatestVersion(Path cacheDir, String mcVer
}
}

return this.artifactInfo.buildVerifiableMetaUrl(this.hashType, executor).thenCompose(verifiableUrl -> {
return this.artifactInfo.buildVerifiableMetaUrl(this.getMetaHashType(), executor).thenCompose(verifiableUrl -> {
LOGGER.info("Fetching latest {} build...", this.name);
return verifiableUrl.get(executor).thenApply(resp -> {
Document document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected CompletableFuture<Void> downloadMappings0(Path cacheDir, Executor exec
}

return future
.thenCompose($ -> HASHED_MAPPINGS_ARTIFACT.buildVerifiableUrl(this.versionData.getId(), "jar", this.hashType, executor))
.thenCompose($ -> HASHED_MAPPINGS_ARTIFACT.buildVerifiableUrl(this.versionData.getId(), "jar", this.getJarHashType(), executor))
.thenCompose(verifiableUrl -> {
LOGGER.info("Downloading hashed {} mappings for {}...", this.name, this.versionData.getId());
return verifiableUrl.get(executor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public class YarnMappingProvider extends BuildBasedMappingProvider {

private static final String REPO_URL = System.getProperty("stackdeobf.yarn.repo-url", "https://maven.fabricmc.net");

// default to false as fabric's maven repository sometimes
// returns invalid checksums after an update for maven-metadata.xml files;
// this should work around https://github.com/booky10/StackDeobfuscator/issues/10
private static final boolean VERIFY_YARN_METADATA_CHECKSUMS =
Boolean.getBoolean("stackdeobf.yarn.verify-metadata-checksums");

private static final MavenArtifactInfo MAPPINGS_ARTIFACT_V1 = MavenArtifactInfo.parse(REPO_URL,
System.getProperty("stackdeobf.yarn.mappings-artifact.v1", "net.fabricmc:yarn"));
private static final MavenArtifactInfo MAPPINGS_ARTIFACT_V2 = MavenArtifactInfo.parse(REPO_URL,
Expand Down Expand Up @@ -62,6 +68,14 @@ private static VerifiableUrl.HashType getHashType(VersionData versionData) {
? VerifiableUrl.HashType.SHA1 : VerifiableUrl.HashType.SHA256;
}

@Override
public VerifiableUrl.HashType getMetaHashType() {
if (!VERIFY_YARN_METADATA_CHECKSUMS) {
return VerifiableUrl.HashType.DUMMY;
}
return super.getMetaHashType();
}

@Override
protected MappingFormat getMappingFormat() {
return getVersionFlags(this.versionData).contains(VersionFlag.NO_V2)
Expand Down

0 comments on commit 30d4cc0

Please sign in to comment.