fix: breaking versions that inherit from a version being renamed
This commit is contained in:
@@ -104,7 +104,7 @@ public final class HMCLModpackInstallTask extends Task<Void> {
|
|||||||
libraryTask = libraryTask.thenComposeAsync(version -> dependency.installLibraryAsync(modpack.getGameVersion(), version, mark.getLibraryId(), mark.getLibraryVersion()));
|
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
|
@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
|
@Override
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
|||||||
}).thenAcceptAsync(analyzer -> {
|
}).thenAcceptAsync(analyzer -> {
|
||||||
Function<String, Consumer<InstallerItem>> removeAction = libraryId -> x -> {
|
Function<String, Consumer<InstallerItem>> removeAction = libraryId -> x -> {
|
||||||
profile.getDependency().removeLibraryAsync(version, libraryId)
|
profile.getDependency().removeLibraryAsync(version, libraryId)
|
||||||
.thenComposeAsync(profile.getRepository()::save)
|
.thenComposeAsync(profile.getRepository()::saveAsync)
|
||||||
.withComposeAsync(profile.getRepository().refreshVersionsAsync())
|
.withComposeAsync(profile.getRepository().refreshVersionsAsync())
|
||||||
.withRunAsync(Schedulers.javafx(), () -> loadVersion(this.profile, this.versionId))
|
.withRunAsync(Schedulers.javafx(), () -> loadVersion(this.profile, this.versionId))
|
||||||
.start();
|
.start();
|
||||||
@@ -122,7 +122,7 @@ public class InstallerListPage extends ListPageBase<InstallerItem> {
|
|||||||
|
|
||||||
private void doInstallOffline(File file) {
|
private void doInstallOffline(File file) {
|
||||||
Task<?> task = profile.getDependency().installLibraryAsync(version, file.toPath())
|
Task<?> task = profile.getDependency().installLibraryAsync(version, file.toPath())
|
||||||
.thenComposeAsync(profile.getRepository()::save)
|
.thenComposeAsync(profile.getRepository()::saveAsync)
|
||||||
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
.thenComposeAsync(profile.getRepository().refreshVersionsAsync());
|
||||||
task.setName(i18n("install.installer.install_offline"));
|
task.setName(i18n("install.installer.install_offline"));
|
||||||
TaskExecutor executor = task.executor(new TaskListener() {
|
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()));
|
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)
|
if (exception != null)
|
||||||
dependencyManager.getGameRepository().removeVersionFromDisk(name);
|
dependencyManager.getGameRepository().removeVersionFromDisk(name);
|
||||||
}).withStagesHint(stages);
|
}).withStagesHint(stages);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class GameInstallTask extends Task<Version> {
|
|||||||
).withStage("hmcl.install.assets").withRunAsync(() -> {
|
).withStage("hmcl.install.assets").withRunAsync(() -> {
|
||||||
// ignore failure
|
// 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()))
|
if (fromVersion.getId().equals(fromVersion.getJar()))
|
||||||
fromVersion = fromVersion.setJar(null);
|
fromVersion = fromVersion.setJar(null);
|
||||||
FileUtils.writeText(toJson.toFile(), JsonUtils.GSON.toJson(fromVersion.setId(to)));
|
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;
|
return true;
|
||||||
} catch (IOException | JsonParseException | VersionNotFoundException | InvalidPathException e) {
|
} catch (IOException | JsonParseException | VersionNotFoundException | InvalidPathException e) {
|
||||||
LOG.log(Level.WARNING, "Unable to rename version " + from + " to " + to, e);
|
LOG.log(Level.WARNING, "Unable to rename version " + from + " to " + to, e);
|
||||||
@@ -408,7 +416,7 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
return assetsDir;
|
return assetsDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Version> save(Version version) {
|
public Task<Version> saveAsync(Version version) {
|
||||||
if (version.isResolvedPreservingPatches()) {
|
if (version.isResolvedPreservingPatches()) {
|
||||||
return new VersionJsonSaveTask(this, MaintainTask.maintainPreservingPatches(this, version));
|
return new VersionJsonSaveTask(this, MaintainTask.maintainPreservingPatches(this, version));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
|
|||||||
FileUtils.copyDirectory(jarmods, repository.getVersionRoot(name).toPath().resolve("jarmods"));
|
FileUtils.copyDirectory(jarmods, repository.getVersionRoot(name).toPath().resolve("jarmods"));
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies.add(repository.save(version));
|
dependencies.add(repository.saveAsync(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user