From b6de9d4ea2b9c421c2c6e8cd68c0204ae143401b Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Sat, 31 Jul 2021 00:55:47 +0800 Subject: [PATCH] fix: failed to duplicate version when no jar --- .../main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 b1d770e57..d1a3c7962 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameRepository.java @@ -129,7 +129,9 @@ public class HMCLGameRepository extends DefaultGameRepository { if (dstDir.exists()) throw new IOException("Version exists"); FileUtils.copyDirectory(srcDir.toPath(), dstDir.toPath()); - Files.move(dstDir.toPath().resolve(srcId + ".jar"), dstDir.toPath().resolve(dstId + ".jar")); + if (Files.exists(dstDir.toPath().resolve(srcId + ".jar"))) { + Files.move(dstDir.toPath().resolve(srcId + ".jar"), dstDir.toPath().resolve(dstId + ".jar")); + } Files.move(dstDir.toPath().resolve(srcId + ".json"), dstDir.toPath().resolve(dstId + ".json")); VersionSetting oldVersionSetting = getVersionSetting(srcId).clone(); GameDirectoryType originalGameDirType = oldVersionSetting.getGameDirType();