diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseInstallTask.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseInstallTask.java index 60a2a1c533..b1190c012c 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseInstallTask.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseInstallTask.java @@ -139,8 +139,20 @@ public Collection> getDependencies() { @Override public void execute() throws Exception { if (config != null) { - // For update, remove mods not listed in new manifest - for (CurseManifestFile oldCurseManifestFile : config.getManifest().files()) { + // For update, remove mods not listed in new manifest. + // ModpackConfiguration stored in modpack.json preserves the raw + // CurseForge manifest where fileName is missing. CurseCompletionTask + // resolves those file names and writes the enriched manifest to + // manifest.json, so read from there when available. + Path oldManifestFile = repository.getVersionRoot(name).resolve("manifest.json"); + List oldFiles = config.getManifest().files(); + if (Files.exists(oldManifestFile)) { + try { + oldFiles = JsonUtils.fromJsonFile(oldManifestFile, CurseManifest.class).files(); + } catch (IOException | JsonParseException ignored) { + } + } + for (CurseManifestFile oldCurseManifestFile : oldFiles) { if (StringUtils.isBlank(oldCurseManifestFile.fileName())) continue; Path oldFile = run.resolve("mods/" + oldCurseManifestFile.fileName()); if (Files.notExists(oldFile)) continue;