Fixed bug which caused large files to be fully downloaded when running tests

This commit is contained in:
cyian-1756 2018-10-06 09:47:44 -04:00
parent 7cca4ff5b2
commit dd9a81a4f5

View File

@ -214,6 +214,7 @@ class DownloadFileThread extends Thread {
} }
byte[] data = new byte[1024 * 256]; byte[] data = new byte[1024 * 256];
int bytesRead; int bytesRead;
boolean shouldSkipFileDownload = huc.getContentLength() / 10000000 >= 10;
while ( (bytesRead = bis.read(data)) != -1) { while ( (bytesRead = bis.read(data)) != -1) {
try { try {
observer.stopCheck(); observer.stopCheck();
@ -228,7 +229,7 @@ class DownloadFileThread extends Thread {
observer.sendUpdate(STATUS.COMPLETED_BYTES, bytesDownloaded); observer.sendUpdate(STATUS.COMPLETED_BYTES, bytesDownloaded);
} }
// If this is a test and we're downloading a large file // 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"); logger.debug("Not downloading whole file because it is over 10mb and this is a test");
bis.close(); bis.close();
fos.close(); fos.close();