From b69602b735dddad3d984183bb9c3601a7a7af96b Mon Sep 17 00:00:00 2001 From: e74yp8 <63497646+e74yp8@users.noreply.github.com> Date: Mon, 12 May 2025 23:21:20 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20#3218:=20=E4=BF=AE=E5=A4=8D=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=B8=B8=E6=88=8F=E7=89=88=E6=9C=AC=E9=87=8C=E7=9A=84?= =?UTF-8?q?=E2=80=9C=E5=A4=8D=E5=88=B6=E5=AD=98=E6=A1=A3=E2=80=9D=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98=20(#3868)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/game/HMCLGameRepository.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java index baa4e3290..242170bd4 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java @@ -151,18 +151,24 @@ public class HMCLGameRepository extends DefaultGameRepository { Version fromVersion = getVersion(srcId); - if (Files.exists(dstDir)) throw new IOException("Version exists"); - FileUtils.copyDirectory(srcDir, dstDir); + List blackList = new ArrayList<>(ModAdviser.MODPACK_BLACK_LIST); + blackList.add(srcId + ".jar"); + blackList.add(srcId + ".json"); + if (!copySaves) + blackList.add("saves"); - Path fromJson = dstDir.resolve(srcId + ".json"); - Path fromJar = dstDir.resolve(srcId + ".jar"); + if (Files.exists(dstDir)) throw new IOException("Version exists"); + FileUtils.copyDirectory(srcDir, dstDir, path -> Modpack.acceptFile(path, blackList, null)); + + Path fromJson = srcDir.resolve(srcId + ".json"); + Path fromJar = srcDir.resolve(srcId + ".jar"); Path toJson = dstDir.resolve(dstId + ".json"); Path toJar = dstDir.resolve(dstId + ".jar"); if (Files.exists(fromJar)) { - Files.move(fromJar, toJar); + Files.copy(fromJar, toJar); } - Files.move(fromJson, toJson); + Files.copy(fromJson, toJson); FileUtils.writeText(toJson.toFile(), JsonUtils.GSON.toJson(fromVersion.setId(dstId))); @@ -176,12 +182,6 @@ public class HMCLGameRepository extends DefaultGameRepository { File srcGameDir = getRunDirectory(srcId); File dstGameDir = getRunDirectory(dstId); - List blackList = new ArrayList<>(ModAdviser.MODPACK_BLACK_LIST); - blackList.add(srcId + ".jar"); - blackList.add(srcId + ".json"); - if (!copySaves) - blackList.add("saves"); - if (originalGameDirType != GameDirectoryType.VERSION_FOLDER) FileUtils.copyDirectory(srcGameDir.toPath(), dstGameDir.toPath(), path -> Modpack.acceptFile(path, blackList, null)); }