Skip to content

Commit 2662eba

Browse files
committed
Reorganize update logic to handle failed downloads before processing preload and restart
1 parent b1cb02b commit 2662eba

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

loader/core/src/main/java/pl/skidam/automodpack_loader_core/client/ModpackUpdater.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,7 @@ public void startUpdate() {
379379
Path cwd = Path.of(System.getProperty("user.dir"));
380380
CustomFileUtils.deleteDummyFiles(cwd, serverModpackContent.list);
381381

382-
if (preload) {
383-
LOGGER.info("Update completed! Took: {}ms", System.currentTimeMillis() - start);
384-
CheckAndLoadModpack();
385-
} else if (failedDownloads.isEmpty()) {
386-
boolean requiredRestart = applyModpack();
387-
LOGGER.info("Update completed! Required restart: {} Took: {}ms", requiredRestart, System.currentTimeMillis() - start);
388-
UpdateType updateType = fullDownload ? UpdateType.FULL : UpdateType.UPDATE;
389-
new ReLauncher(modpackDir, updateType, changelogs).restart(false);
390-
} else {
382+
if (!failedDownloads.isEmpty()) {
391383
StringBuilder failedFiles = new StringBuilder();
392384
for (var download : failedDownloads.entrySet()) {
393385
var item = download.getKey();
@@ -398,6 +390,14 @@ public void startUpdate() {
398390

399391
new ScreenManager().error("automodpack.error.files", "Failed to download: " + failedFiles, "automodpack.error.logs");
400392
LOGGER.error("Update failed successfully! Try again! Took: {}ms", System.currentTimeMillis() - start);
393+
} else if (preload) {
394+
LOGGER.info("Update completed! Took: {}ms", System.currentTimeMillis() - start);
395+
CheckAndLoadModpack();
396+
} else {
397+
boolean requiredRestart = applyModpack();
398+
LOGGER.info("Update completed! Required restart: {} Took: {}ms", requiredRestart, System.currentTimeMillis() - start);
399+
UpdateType updateType = fullDownload ? UpdateType.FULL : UpdateType.UPDATE;
400+
new ReLauncher(modpackDir, updateType, changelogs).restart(false);
401401
}
402402
} catch (SocketTimeoutException | ConnectException e) {
403403
LOGGER.error("{} is not responding", "Modpack host of " + modpackAddresses.hostAddress, e);

0 commit comments

Comments
 (0)