fix: not generating modpack.cfg when CurseCompletionTask fail

This commit is contained in:
huanghongxun 2020-04-17 23:46:08 +08:00
parent 5893eae87f
commit 859da37d71
5 changed files with 12 additions and 8 deletions

View File

@ -77,6 +77,7 @@ public final class HMCLModpackInstallTask extends Task<Void> {
} catch (JsonParseException | IOException ignore) {
}
dependents.add(new ModpackInstallTask<>(zipFile, run, modpack.getEncoding(), "/minecraft", it -> !"pack.json".equals(it), config));
dependents.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/minecraft", modpack, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override
@ -104,7 +105,6 @@ public final class HMCLModpackInstallTask extends Task<Void> {
}
dependencies.add(libraryTask.thenComposeAsync(repository::save));
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/minecraft", modpack, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override

View File

@ -89,7 +89,8 @@ public class ModpackInstallTask<T> extends Task<Void> {
// If both old and new modpacks have this entry, but the file is deleted by user, leave it missing.
return false;
} else {
// If user modified this entry file, we will not replace this file since this modified file is that user expects.
// If both old and new modpacks have this entry, and user has modified this file,
// we will not replace it since this modified file is what user expects.
String fileHash = encodeHex(digest("SHA-1", Files.newInputStream(destPath)));
String oldHash = files.get(entryPath).getHash();
return Objects.equals(oldHash, fileHash);

View File

@ -107,7 +107,9 @@ public final class CurseInstallTask extends Task<Void> {
}
this.config = config;
dependents.add(new ModpackInstallTask<>(zipFile, run, modpack.getEncoding(), manifest.getOverrides(), any -> true, config).withStage("hmcl.modpack"));
dependents.add(new CurseCompletionTask(dependencyManager, name, manifest).withStage("hmcl.modpack.download"));
dependents.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), manifest.getOverrides(), manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
dependencies.add(new CurseCompletionTask(dependencyManager, name, manifest).withStage("hmcl.modpack.download"));
}
@Override
@ -122,7 +124,8 @@ public final class CurseInstallTask extends Task<Void> {
@Override
public void execute() throws Exception {
if (config != null)
if (config != null) {
// For update, remove mods not listed in new manifest
for (CurseManifestFile oldCurseManifestFile : config.getManifest().getFiles()) {
if (StringUtils.isBlank(oldCurseManifestFile.getFileName())) continue;
File oldFile = new File(run, "mods/" + oldCurseManifestFile.getFileName());
@ -131,11 +134,10 @@ public final class CurseInstallTask extends Task<Void> {
if (!oldFile.delete())
throw new IOException("Unable to delete mod file " + oldFile);
}
}
File root = repository.getVersionRoot(name);
FileUtils.writeText(new File(root, "manifest.json"), JsonUtils.GSON.toJson(manifest));
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), manifest.getOverrides(), manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override

View File

@ -134,6 +134,8 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
else if (Files.exists(fs.getPath("/" + manifest.getName() + "/minecraft")))
dependents.add(new ModpackInstallTask<>(zipFile, run, modpack.getEncoding(), "/" + manifest.getName() + "/minecraft", any -> true, config).withStage("hmcl.modpack"));
}
dependents.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/" + manifest.getName() + "/minecraft", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override
@ -179,7 +181,6 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
}
dependencies.add(repository.save(version));
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/" + manifest.getName() + "/minecraft", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override

View File

@ -82,6 +82,7 @@ public class ServerModpackLocalInstallTask extends Task<Void> {
} catch (JsonParseException | IOException ignore) {
}
dependents.add(new ModpackInstallTask<>(zipFile, run, modpack.getEncoding(), "/overrides", any -> true, config).withStage("hmcl.modpack"));
dependents.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/overrides", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override
@ -96,7 +97,6 @@ public class ServerModpackLocalInstallTask extends Task<Void> {
@Override
public void execute() throws Exception {
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/overrides", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)).withStage("hmcl.modpack"));
}
@Override