From 21a86d8287a8f16fb02953d96a99b806a74fa0c8 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 7 Oct 2018 09:00:46 -0400 Subject: [PATCH] Moved if statement outide of loop --- .../ripme/ripper/DownloadFileThread.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java index 2f8a1503..7188390f 100644 --- a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java +++ b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java @@ -214,27 +214,24 @@ class DownloadFileThread extends Thread { } byte[] data = new byte[1024 * 256]; int bytesRead; - boolean shouldSkipFileDownload = huc.getContentLength() / 10000000 >= 10; - while ( (bytesRead = bis.read(data)) != -1) { - try { - observer.stopCheck(); - } catch (IOException e) { - observer.downloadErrored(url, rb.getString("download.interrupted")); - return; - } - fos.write(data, 0, bytesRead); - if (observer.useByteProgessBar()) { - bytesDownloaded += bytesRead; - observer.setBytesCompleted(bytesDownloaded); - observer.sendUpdate(STATUS.COMPLETED_BYTES, bytesDownloaded); - } - // If this is a test and we're downloading a large file - if (AbstractRipper.isThisATest() && shouldSkipFileDownload) { - logger.debug("Not downloading whole file because it is over 10mb and this is a test"); - bis.close(); - fos.close(); - break; - + boolean shouldSkipFileDownload = huc.getContentLength() / 10000000 >= 10 && AbstractRipper.isThisATest(); + // If this is a test rip we skip large downloads + if (shouldSkipFileDownload) { + logger.debug("Not downloading whole file because it is over 10mb and this is a test"); + } else { + while ((bytesRead = bis.read(data)) != -1) { + try { + observer.stopCheck(); + } catch (IOException e) { + observer.downloadErrored(url, rb.getString("download.interrupted")); + return; + } + fos.write(data, 0, bytesRead); + if (observer.useByteProgessBar()) { + bytesDownloaded += bytesRead; + observer.setBytesCompleted(bytesDownloaded); + observer.sendUpdate(STATUS.COMPLETED_BYTES, bytesDownloaded); + } } } bis.close();