From c52c34ab999d7982a7f5afc63f8912024e52b995 Mon Sep 17 00:00:00 2001 From: soloturn Date: Sat, 20 Mar 2021 10:10:09 +0100 Subject: [PATCH] load history should not produce NPE, ripme#1853 see: * https://github.com/RipMeApp/ripme/issues/1853 * https://stackoverflow.com/questions/20714058/file-exists-and-is-directory-but-listfiles-returns-null --- .../java/com/rarchives/ripme/ui/MainWindow.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index 92b8071c..48e8d836 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -1183,13 +1183,15 @@ public final class MainWindow implements Runnable, RipStatusHandler { // Guess rip history based on rip folder String[] dirs = Utils.getWorkingDirectory() .list((dir, file) -> new File(dir.getAbsolutePath() + File.separator + file).isDirectory()); - for (String dir : dirs) { - String url = RipUtils.urlFromDirectoryName(dir); - if (url != null) { - // We found one, add it to history - HistoryEntry entry = new HistoryEntry(); - entry.url = url; - HISTORY.add(entry); + if (dirs != null) { + for (String dir : dirs) { + String url = RipUtils.urlFromDirectoryName(dir); + if (url != null) { + // We found one, add it to history + HistoryEntry entry = new HistoryEntry(); + entry.url = url; + HISTORY.add(entry); + } } } }