mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-07 17:36:52 +08:00
fix: breaking versions that inherit from a version being renamed
This commit is contained in:
parent
9bda50f66e
commit
bc842437fa
@ -104,7 +104,7 @@ public final class HMCLModpackInstallTask extends Task<Void> {
|
||||
libraryTask = libraryTask.thenComposeAsync(version -> dependency.installLibraryAsync(modpack.getGameVersion(), version, mark.getLibraryId(), mark.getLibraryVersion()));
|
||||
}
|
||||
|
||||
dependencies.add(libraryTask.thenComposeAsync(repository::save));
|
||||
dependencies.add(libraryTask.thenComposeAsync(repository::saveAsync));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +96,7 @@ public final class UpdateInstallerWizardProvider implements WizardProvider {
|
||||
}
|
||||
}
|
||||
|
||||
return ret.thenComposeAsync(profile.getRepository()::save).thenComposeAsync(profile.getRepository().refreshVersionsAsync()).withStagesHint(stages);
|
||||
return ret.thenComposeAsync(profile.getRepository()::saveAsync).thenComposeAsync(profile.getRepository().refreshVersionsAsync()).withStagesHint(stages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +76,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
||||
}).thenAcceptAsync(analyzer -> {
|
||||
Function<String, Consumer<InstallerItem>> removeAction = libraryId -> x -> {
|
||||
profile.getDependency().removeLibraryAsync(version, libraryId)
|
||||
.thenComposeAsync(profile.getRepository()::save)
|
||||
.thenComposeAsync(profile.getRepository()::saveAsync)
|
||||
.withComposeAsync(profile.getRepository().refreshVersionsAsync())
|
||||
.withRunAsync(Schedulers.javafx(), () -> loadVersion(this.profile, this.versionId))
|
||||
.start();
|
||||
@ -122,7 +122,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
||||
|
||||
private void doInstallOffline(File file) {
|
||||
Task<?> task = profile.getDependency().installLibraryAsync(version, file.toPath())
|
||||
.thenComposeAsync(profile.getRepository()::save)
|
||||
.thenComposeAsync(profile.getRepository()::saveAsync)
|
||||
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||
task.setName(i18n("install.installer.install_offline"));
|
||||
TaskExecutor executor = task.executor(new TaskListener() {
|
||||
|
@ -60,7 +60,7 @@ public class DefaultGameBuilder extends GameBuilder {
|
||||
stages.add(String.format("hmcl.install.%s:%s", remoteVersion.getLibraryId(), remoteVersion.getSelfVersion()));
|
||||
}
|
||||
|
||||
return libraryTask.thenComposeAsync(dependencyManager.getGameRepository()::save).whenComplete(exception -> {
|
||||
return libraryTask.thenComposeAsync(dependencyManager.getGameRepository()::saveAsync).whenComplete(exception -> {
|
||||
if (exception != null)
|
||||
dependencyManager.getGameRepository().removeVersionFromDisk(name);
|
||||
}).withStagesHint(stages);
|
||||
|
@ -77,7 +77,7 @@ public class GameInstallTask extends Task<Version> {
|
||||
).withStage("hmcl.install.assets").withRunAsync(() -> {
|
||||
// ignore failure
|
||||
})
|
||||
).thenComposeAsync(gameRepository.save(version)));
|
||||
).thenComposeAsync(gameRepository.saveAsync(version)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -180,6 +180,14 @@ public class DefaultGameRepository implements GameRepository {
|
||||
if (fromVersion.getId().equals(fromVersion.getJar()))
|
||||
fromVersion = fromVersion.setJar(null);
|
||||
FileUtils.writeText(toJson.toFile(), JsonUtils.GSON.toJson(fromVersion.setId(to)));
|
||||
|
||||
// fix inheritsFrom of versions that inherits from version [from].
|
||||
for (Version version : getVersions()) {
|
||||
if (from.equals(version.getInheritsFrom())) {
|
||||
File json = getVersionJson(version.getId()).getAbsoluteFile();
|
||||
FileUtils.writeText(json, JsonUtils.GSON.toJson(version.setInheritsFrom(to)));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (IOException | JsonParseException | VersionNotFoundException | InvalidPathException e) {
|
||||
LOG.log(Level.WARNING, "Unable to rename version " + from + " to " + to, e);
|
||||
@ -408,7 +416,7 @@ public class DefaultGameRepository implements GameRepository {
|
||||
return assetsDir;
|
||||
}
|
||||
|
||||
public Task<Version> save(Version version) {
|
||||
public Task<Version> saveAsync(Version version) {
|
||||
if (version.isResolvedPreservingPatches()) {
|
||||
return new VersionJsonSaveTask(this, MaintainTask.maintainPreservingPatches(this, version));
|
||||
} else {
|
||||
|
@ -180,7 +180,7 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
|
||||
FileUtils.copyDirectory(jarmods, repository.getVersionRoot(name).toPath().resolve("jarmods"));
|
||||
}
|
||||
|
||||
dependencies.add(repository.save(version));
|
||||
dependencies.add(repository.saveAsync(version));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user