fix: unable to rename game versions that do not have jar file in directory.

This commit is contained in:
huanghongxun 2021-10-22 21:17:49 +08:00
parent 85a9a21e57
commit 192a0c987e

View File

@ -216,13 +216,15 @@ public class DefaultGameRepository implements GameRepository {
Path toJson = toDir.resolve(to + ".json");
Path toJar = toDir.resolve(to + ".jar");
boolean hasJarFile = Files.exists(fromJar);
try {
Files.move(fromJson, toJson);
Files.move(fromJar, toJar);
if (hasJarFile) Files.move(fromJar, toJar);
} catch (IOException e) {
// recovery
Lang.ignoringException(() -> Files.move(toJson, fromJson));
Lang.ignoringException(() -> Files.move(toJar, fromJar));
if (hasJarFile) Lang.ignoringException(() -> Files.move(toJar, fromJar));
Lang.ignoringException(() -> Files.move(toDir, fromDir));
throw e;
}