Skip to content

fix(curse): fix mod conflicts during modpack update #6190

Open
fatelove42 wants to merge 1 commit into
HMCL-dev:mainfrom
fatelove42:fix/curse-update-conflict
Open

fix(curse): fix mod conflicts during modpack update #6190
fatelove42 wants to merge 1 commit into
HMCL-dev:mainfrom
fatelove42:fix/curse-update-conflict

Conversation

@fatelove42

@fatelove42 fatelove42 commented Jun 16, 2026

Copy link
Copy Markdown

Fix

Fixed an issue where old version mods were not deleted during CurseForge modpack updates, resulting in both old and new mods coexisting and causing ResolutionException (e.g., CrashAssistant conflicts).

Root Cause

In CurseInstallTask.execute(), the data source for reading the old file list was incorrect:

  1. The original logic read the old file list from config.getManifest() (modpack.cfg/modpack.json).
  2. This configuration file only stores projectID and fileID, while the fileName field is blank.
  3. As a result, the isBlank() check at L144 always evaluated to true, directly continueing and skipping the cleanup of old files.

Solution

Changed the source of the old file list from config to the manifest.json located in the version root directory (which is written by CurseCompletionTask and contains the complete fileName info).
This allows the installation task to correctly obtain the old file names and delete them before installing new mods, preventing duplicate installations.
#4315
#6185

@fatelove42

Copy link
Copy Markdown
Author

/gemini review

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

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.

Code Review

This pull request updates CurseInstallTask.java to read previous file names from manifest.json instead of the modpack configuration, which fixes an issue where outdated mods were not being removed during updates. The review feedback points out a potential NullPointerException if the parsed manifest or its files list is null, and suggests adding defensive null checks.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +149 to +156
CurseManifest oldManifest = JsonUtils.fromJsonFile(oldManifestFile, CurseManifest.class);
for (CurseManifestFile oldCurseManifestFile : oldManifest.files()) {
if (StringUtils.isBlank(oldCurseManifestFile.fileName())) continue;
Path oldFile = run.resolve("mods/" + oldCurseManifestFile.fileName());
if (Files.notExists(oldFile)) continue;
if (manifest.files().stream().noneMatch(oldCurseManifestFile::equals))
Files.deleteIfExists(oldFile);
}

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

The JsonUtils.fromJsonFile method can return null if the file is empty or invalid. Additionally, oldManifest.files() can also be null if the files field is missing in the JSON. To prevent a potential NullPointerException, we should add defensive null checks for both oldManifest and oldManifest.files() before iterating over the files.

                    CurseManifest oldManifest = JsonUtils.fromJsonFile(oldManifestFile, CurseManifest.class);
                    if (oldManifest != null && oldManifest.files() != null) {
                        for (CurseManifestFile oldCurseManifestFile : oldManifest.files()) {
                            if (StringUtils.isBlank(oldCurseManifestFile.fileName())) continue;
                            Path oldFile = run.resolve("mods/" + oldCurseManifestFile.fileName());
                            if (Files.notExists(oldFile)) continue;
                            if (manifest.files().stream().noneMatch(oldCurseManifestFile::equals))
                                Files.deleteIfExists(oldFile);
                        }
                    }

@fatelove42

Copy link
Copy Markdown
Author

已在atm9整合包升级中测试过确定问题已修复

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.

1 participant