diff --git a/src/main/java/io/bioimage/modelrunner/engine/installation/FileDownloader.java b/src/main/java/io/bioimage/modelrunner/engine/installation/FileDownloader.java index 40315d81..9fb7361d 100644 --- a/src/main/java/io/bioimage/modelrunner/engine/installation/FileDownloader.java +++ b/src/main/java/io/bioimage/modelrunner/engine/installation/FileDownloader.java @@ -76,7 +76,7 @@ public void call(Thread parentThread) throws IOException, InterruptedException { } position += transferred; - if (parentThread.isInterrupted()) { + if (!parentThread.isAlive()) { // Close resources if needed and exit closeResources(); throw new InterruptedException("File download was interrupted."); diff --git a/src/main/java/io/bioimage/modelrunner/utils/ZipUtils.java b/src/main/java/io/bioimage/modelrunner/utils/ZipUtils.java index 22815ac9..d8b4c781 100644 --- a/src/main/java/io/bioimage/modelrunner/utils/ZipUtils.java +++ b/src/main/java/io/bioimage/modelrunner/utils/ZipUtils.java @@ -145,7 +145,7 @@ public static long getUncompressedSize(File zipFile, Thread parentThread) throws try (ZipFile zip = new ZipFile(zipFile)) { Enumeration entries = zip.entries(); - while (entries.hasMoreElements() && !parentThread.isInterrupted()) { + while (entries.hasMoreElements() && parentThread.isAlive()) { ZipEntry entry = entries.nextElement(); // Skip directories @@ -171,7 +171,7 @@ private static long calculateEntrySize(ZipFile zip, ZipEntry entry, Thread paren try (InputStream is = zip.getInputStream(entry)) { int read; - while ((read = is.read(buffer)) != -1 && !parentThread.isInterrupted()) { + while ((read = is.read(buffer)) != -1 && parentThread.isAlive()) { size += read; } }