From ca4a13589d027d7c74e38ea40c5e83e9b336225e Mon Sep 17 00:00:00 2001 From: comp500 <comp500@users.noreply.github.com> Date: Sun, 11 Aug 2019 22:37:42 +0100 Subject: [PATCH] Fix crash on empty index file --- .../java/link/infra/packwiz/installer/UpdateManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/link/infra/packwiz/installer/UpdateManager.java b/src/main/java/link/infra/packwiz/installer/UpdateManager.java index de48ade..f4645a6 100644 --- a/src/main/java/link/infra/packwiz/installer/UpdateManager.java +++ b/src/main/java/link/infra/packwiz/installer/UpdateManager.java @@ -296,6 +296,10 @@ public class UpdateManager { ui.submitProgress(new InstallProgress("Comparing new files...")); // TODO: progress bar? + if (indexFile.files == null || indexFile.files.size() == 0) { + System.out.println("Warning: Index is empty!"); + indexFile.files = new ArrayList<>(); + } List<DownloadTask> tasks = DownloadTask.createTasksFromIndex(indexFile, indexFile.hashFormat, opts.side); // If the side changes, invalidate EVERYTHING just in case // Might not be needed, but done just to be safe @@ -328,7 +332,7 @@ public class UpdateManager { tasks.parallelStream().forEach(f -> f.downloadMetadata(indexFile, indexUri)); List<IExceptionDetails> failedTasks = tasks.stream().filter(t -> t.getException() != null).collect(Collectors.toList()); - if (failedTasks.size() > 0) { + if (!failedTasks.isEmpty()) { IExceptionDetails.ExceptionListResult exceptionListResult; try { exceptionListResult = ui.showExceptions(failedTasks, tasks.size(), true).get();