From 0cba5ba17b8ad85fcd0dcd2b16b29ea8a474d947 Mon Sep 17 00:00:00 2001 From: comp500 Date: Mon, 12 Aug 2019 02:17:28 +0100 Subject: [PATCH] Ensure index and pack files are rechecked after errors --- .../infra/packwiz/installer/UpdateManager.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/link/infra/packwiz/installer/UpdateManager.java b/src/main/java/link/infra/packwiz/installer/UpdateManager.java index f4645a6..6bf72b6 100644 --- a/src/main/java/link/infra/packwiz/installer/UpdateManager.java +++ b/src/main/java/link/infra/packwiz/installer/UpdateManager.java @@ -35,6 +35,7 @@ public class UpdateManager { private boolean cancelled; private boolean cancelledStartGame = false; private InputStateHandler stateHandler; + private boolean errorsOccurred = false; public static class Options { SpaceSafeURI downloadURI = null; @@ -199,7 +200,14 @@ public class UpdateManager { // TODO: update MMC params, java args etc - manifest.packFileHash = packFileSource.getHash(); + // If there were errors, don't write the manifest/index hashes, to ensure they are rechecked later + if (errorsOccurred) { + manifest.indexFileHash = null; + manifest.packFileHash = null; + } else { + manifest.packFileHash = packFileSource.getHash(); + } + manifest.cachedSide = opts.side; try (Writer writer = new FileWriter(Paths.get(opts.packFolder, opts.manifestFile).toString())) { gson.toJson(manifest, writer); @@ -333,6 +341,7 @@ public class UpdateManager { List failedTasks = tasks.stream().filter(t -> t.getException() != null).collect(Collectors.toList()); if (!failedTasks.isEmpty()) { + errorsOccurred = true; IExceptionDetails.ExceptionListResult exceptionListResult; try { exceptionListResult = ui.showExceptions(failedTasks, tasks.size(), true).get(); @@ -430,7 +439,8 @@ public class UpdateManager { } List failedTasks2ElectricBoogaloo = nonFailedFirstTasks.stream().filter(t -> t.getException() != null).collect(Collectors.toList()); - if (failedTasks2ElectricBoogaloo.size() > 0) { + if (!failedTasks2ElectricBoogaloo.isEmpty()) { + errorsOccurred = true; IExceptionDetails.ExceptionListResult exceptionListResult; try { exceptionListResult = ui.showExceptions(failedTasks2ElectricBoogaloo, tasks.size(), false).get();