Skip to content

检测到系统 zlib 实现为 zlib-ng 时跳过 Forge/NeoForge 安装时的哈希检测#6068

Merged
Glavo merged 6 commits into
HMCL-dev:mainfrom
Glavo:forge-skip-hash
May 8, 2026
Merged

检测到系统 zlib 实现为 zlib-ng 时跳过 Forge/NeoForge 安装时的哈希检测#6068
Glavo merged 6 commits into
HMCL-dev:mainfrom
Glavo:forge-skip-hash

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented May 6, 2026

No description provided.

… verification for dynamically generated JARs
@Glavo Glavo marked this pull request as draft May 6, 2026 13:54
@Glavo Glavo marked this pull request as ready for review May 8, 2026 04:03
@Glavo Glavo linked an issue May 8, 2026 that may be closed by this pull request
@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented May 8, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a ZlibUtils utility to detect if the system's zlib implementation produces standard compressed output. This is used to prevent installation failures in ForgeNewInstallTask when alternative libraries like zlib-ng cause SHA-1 mismatches in dynamically generated JARs; in such cases, the system now falls back to a structural integrity check. Review feedback suggests avoiding wildcard imports in Launcher.java, using case-insensitive comparisons for file extensions, and declaring the IS_ZLIB_COMPATIBLE flag as final.

import org.jackhuang.hmcl.util.FileSaver;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

建议避免使用通配符导入(wildcard import)。根据 Google Java 编程风格指南以及本项目现有的代码风格,应当使用具体的类导入,以提高代码的可读性并避免潜在的命名冲突。

Suggested change
import org.jackhuang.hmcl.util.*;
import org.jackhuang.hmcl.util.CrashReporter;
import org.jackhuang.hmcl.util.FileSaver;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.ZlibUtils;

}

if (!Objects.equals(code, entry.getValue())) {
if (!ZlibUtils.IS_ZLIB_COMPATIBLE && FileUtils.getExtension(artifact).equals("jar")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

检查文件扩展名时,建议使用不区分大小写的比较(如 equalsIgnoreCase),以确保在处理具有大写扩展名(如 .JAR)的文件时也能正确触发逻辑。

Suggested change
if (!ZlibUtils.IS_ZLIB_COMPATIBLE && FileUtils.getExtension(artifact).equals("jar")) {
if (!ZlibUtils.IS_ZLIB_COMPATIBLE && "jar".equalsIgnoreCase(FileUtils.getExtension(artifact))) {

Comment thread HMCLCore/src/main/java/org/jackhuang/hmcl/util/ZlibUtils.java Outdated
@Glavo Glavo merged commit 996c9f4 into HMCL-dev:main May 8, 2026
2 checks passed
@Glavo Glavo deleted the forge-skip-hash branch May 8, 2026 04:13
@CFKBD2026
Copy link
Copy Markdown

Glavo你真是活跃。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 下载整合包时 Forge 哈希检验不通过

3 participants