standardize all Downloaders on 8k block sizes

This is needed since this affects the onProgress broadcasts, and sending
too many can peg the device's CPU.  1k was just too small.  ANd 8k works
fine for Bluetooth.

This commit is contained in:
Hans-Christoph Steiner 2019-03-29 16:37:18 +01:00
parent 06b9abcee3
commit 66e909d606
5 changed files with 6 additions and 6 deletions

@ -92,7 +92,7 @@ public class BluetoothDownloader extends Downloader {
@Override @Override
public void download() throws IOException, InterruptedException { public void download() throws IOException, InterruptedException {
downloadFromStream(1024, false); downloadFromStream(false);
connection.closeQuietly(); connection.closeQuietly();
} }

@ -116,7 +116,7 @@ public abstract class Downloader {
return notFound; return notFound;
} }
void downloadFromStream(int bufferSize, boolean resumable) throws IOException, InterruptedException { void downloadFromStream(boolean resumable) throws IOException, InterruptedException {
Utils.debugLog(TAG, "Downloading from stream"); Utils.debugLog(TAG, "Downloading from stream");
InputStream input = null; InputStream input = null;
OutputStream outputStream = new FileOutputStream(outputFile, resumable); OutputStream outputStream = new FileOutputStream(outputFile, resumable);
@ -127,7 +127,7 @@ public abstract class Downloader {
// we were interrupted before proceeding to the download. // we were interrupted before proceeding to the download.
throwExceptionIfInterrupted(); throwExceptionIfInterrupted();
copyInputToOutputStream(input, bufferSize, outputStream); copyInputToOutputStream(input, 8192, outputStream);
} finally { } finally {
Utils.closeQuietly(outputStream); Utils.closeQuietly(outputStream);
Utils.closeQuietly(input); Utils.closeQuietly(input);

@ -175,7 +175,7 @@ public class HttpDownloader extends Downloader {
} }
setupConnection(resumable); setupConnection(resumable);
Utils.debugLog(TAG, "downloading " + urlString + " (is resumable: " + resumable + ")"); Utils.debugLog(TAG, "downloading " + urlString + " (is resumable: " + resumable + ")");
downloadFromStream(8192, resumable); downloadFromStream(resumable);
cacheTag = connection.getHeaderField(HEADER_FIELD_ETAG); cacheTag = connection.getHeaderField(HEADER_FIELD_ETAG);
} }

@ -81,6 +81,6 @@ public class LocalFileDownloader extends Downloader {
} else if (fileLength > 0) { } else if (fileLength > 0) {
resumable = true; resumable = true;
} }
downloadFromStream(8192, resumable); downloadFromStream(resumable);
} }
} }

@ -96,7 +96,7 @@ public class TreeUriDownloader extends Downloader {
@Override @Override
public void download() throws IOException, InterruptedException { public void download() throws IOException, InterruptedException {
downloadFromStream(8192, false); downloadFromStream(false);
} }
@Override @Override