From dd9a81a4f54595680e6f5dacc8bf713f577381fd Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 6 Oct 2018 09:47:44 -0400 Subject: [PATCH] Fixed bug which caused large files to be fully downloaded when running tests --- .../java/com/rarchives/ripme/ripper/DownloadFileThread.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java index 85a8f64d..2f8a1503 100644 --- a/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java +++ b/src/main/java/com/rarchives/ripme/ripper/DownloadFileThread.java @@ -214,6 +214,7 @@ 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(); @@ -228,7 +229,7 @@ class DownloadFileThread extends Thread { observer.sendUpdate(STATUS.COMPLETED_BYTES, bytesDownloaded); } // If this is a test and we're downloading a large file - if (AbstractRipper.isThisATest() && bytesTotal / 10000000 >= 10) { + if (AbstractRipper.isThisATest() && shouldSkipFileDownload) { logger.debug("Not downloading whole file because it is over 10mb and this is a test"); bis.close(); fos.close();