mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-11 04:46:18 -04:00
fix: cannot launch fabric 1.18 experimental version. Closes #950.
This commit is contained in:
parent
0210b9fd3d
commit
19bcf453a5
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Hello Minecraft! Launcher
|
* Hello Minecraft! Launcher
|
||||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -314,11 +314,31 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!id.equals(version.getId())) {
|
if (!id.equals(version.getId())) {
|
||||||
version = version.setId(id);
|
|
||||||
try {
|
try {
|
||||||
FileUtils.writeText(json, JsonUtils.GSON.toJson(version));
|
String from = id;
|
||||||
} catch (Exception e) {
|
String to = version.getId();
|
||||||
LOG.log(Level.WARNING, "Ignoring version " + id + " because wrong id " + version.getId() + " is set and cannot correct it.", e);
|
Path fromDir = getVersionRoot(from).toPath();
|
||||||
|
Path toDir = getVersionRoot(to).toPath();
|
||||||
|
Files.move(fromDir, toDir);
|
||||||
|
|
||||||
|
Path fromJson = toDir.resolve(from + ".json");
|
||||||
|
Path fromJar = toDir.resolve(from + ".jar");
|
||||||
|
Path toJson = toDir.resolve(to + ".json");
|
||||||
|
Path toJar = toDir.resolve(to + ".jar");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.move(fromJson, toJson);
|
||||||
|
if (Files.exists(fromJar))
|
||||||
|
Files.move(fromJar, toJar);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// recovery
|
||||||
|
Lang.ignoringException(() -> Files.move(toJson, fromJson));
|
||||||
|
Lang.ignoringException(() -> Files.move(toJar, fromJar));
|
||||||
|
Lang.ignoringException(() -> Files.move(toDir, fromDir));
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.log(Level.WARNING, "Ignoring version " + version.getId() + " because version id does not match folder name " + id + ", and we cannot correct it.", e);
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user