Skip to content

Commit

Permalink
Workaround for ignoring forge processor outputs.
Browse files Browse the repository at this point in the history
We have seen zlib-ng starting to gain popularity. This is causing issues as it generates different deflate blobs compared to regular zlib. Forge installers rely on the output semantics of zlib, as it builds jars.

Ideally Forge should probably just not compress these zips, as this will be an ongoing issue. But this is nothing we have control over here.
  • Loading branch information
covers1624 committed Jul 30, 2024
1 parent 8e9bd9b commit df14ba1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.creeperhost.creeperlauncher.minecraft.jsons.VersionManifest;
import net.creeperhost.creeperlauncher.pack.CancellationToken;
import net.creeperhost.creeperlauncher.pack.Instance;
import net.creeperhost.creeperlauncher.storage.settings.Settings;
import net.creeperhost.creeperlauncher.util.StreamGobblerLog;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -327,7 +328,11 @@ private void runProcessor(@Nullable CancellationToken cancelToken, VersionManife
LOGGER.warn("Output '{}' failed to validate.", output);
LOGGER.warn(" Expected: {}", value);
LOGGER.warn(" Got : {}", hash);
validated = false;
if (Settings.ignoreForgeProcessorOutputHashes()) {
LOGGER.warn("Ignoring invalid hash. Workaround active.");
} else {
validated = false;
}
} else {
LOGGER.info("Output '{}' Validated: {}", output, hash);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ public static long getSpeedLimit() {
public static int getThreadLimit() {
return settingsData.download().threadLimit();
}

public static boolean ignoreForgeProcessorOutputHashes() {
return settingsData.workaround().ignoreForgeProcessorOutputHashes();
}

public static final String DEFAULT_SPEC = "1.0.0";

Expand Down Expand Up @@ -213,6 +217,9 @@ private SettingsData migrate() {
new SettingsData.DownloadSettings(
getOrDefault("threadLimit", Integer::parseInt, DEFAULT_SETTINGS.download().threadLimit()),
getOrDefault("speedLimit", Long::parseLong, DEFAULT_SETTINGS.download().speedLimit())
),
new SettingsData.WorkaroundSettings(
false
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public class SettingsData {
private AppearanceSettings appearance;
private ProxySettings proxy;
private DownloadSettings download;
private WorkaroundSettings workaround;

public SettingsData(String spec, Path instanceLocation, GeneralSettings general, InstanceSettings instanceDefaults, AppearanceSettings appearance, ProxySettings proxy, DownloadSettings download) {
public SettingsData(String spec, Path instanceLocation, GeneralSettings general, InstanceSettings instanceDefaults, AppearanceSettings appearance, ProxySettings proxy, DownloadSettings download, WorkaroundSettings workaround) {
this.spec = spec;
this.instanceLocation = instanceLocation;
this.general = general;
this.instanceDefaults = instanceDefaults;
this.appearance = appearance;
this.proxy = proxy;
this.download = download;
this.workaround = workaround;
}

// Writer
Expand Down Expand Up @@ -110,6 +112,9 @@ public static SettingsData createDefault() {
new DownloadSettings(
Settings.getDefaultThreadLimit(),
0
),
new WorkaroundSettings(
false
)
);
}
Expand Down Expand Up @@ -152,6 +157,10 @@ public DownloadSettings download() {
return download;
}

public WorkaroundSettings workaround() {
return workaround;
}

public void setSpec(String spec) {
this.spec = spec;
}
Expand Down Expand Up @@ -390,4 +399,17 @@ public long speedLimit() {
return speedLimit;
}
}

public static final class WorkaroundSettings {

public boolean ignoreForgeProcessorOutputHashes;

public WorkaroundSettings(boolean ignoreForgeProcessorOutputHashes) {
this.ignoreForgeProcessorOutputHashes = ignoreForgeProcessorOutputHashes;
}

public boolean ignoreForgeProcessorOutputHashes() {
return ignoreForgeProcessorOutputHashes;
}
}
}

0 comments on commit df14ba1

Please sign in to comment.