diff --git a/core/src/main/java/com/threerings/getdown/net/DownloadAbortedException.java b/core/src/main/java/com/threerings/getdown/net/DownloadAbortedException.java deleted file mode 100644 index 77760df..0000000 --- a/core/src/main/java/com/threerings/getdown/net/DownloadAbortedException.java +++ /dev/null @@ -1,15 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2016 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.net; - -import java.io.IOException; - -/** - * Used to terminate the download process in its midst. - */ -public class DownloadAbortedException extends IOException -{ -} diff --git a/core/src/main/java/com/threerings/getdown/net/Downloader.java b/core/src/main/java/com/threerings/getdown/net/Downloader.java index 277478f..f5a8c36 100644 --- a/core/src/main/java/com/threerings/getdown/net/Downloader.java +++ b/core/src/main/java/com/threerings/getdown/net/Downloader.java @@ -211,9 +211,6 @@ public abstract class Downloader /** The bytes downloaded for each resource. */ protected Map _downloaded = new HashMap<>(); - /** Used while downloading. */ - protected byte[] _buffer = new byte[4096]; - /** The time at which the file transfer began. */ protected long _start; diff --git a/core/src/main/java/com/threerings/getdown/net/HTTPDownloader.java b/core/src/main/java/com/threerings/getdown/net/HTTPDownloader.java index acd78c0..9f3be58 100644 --- a/core/src/main/java/com/threerings/getdown/net/HTTPDownloader.java +++ b/core/src/main/java/com/threerings/getdown/net/HTTPDownloader.java @@ -69,6 +69,7 @@ public class HTTPDownloader extends Downloader long actualSize = conn.getContentLength(); log.info("Downloading resource", "url", rsrc.getRemote(), "size", actualSize); long currentSize = 0L; + byte[] buffer = new byte[4*4096]; try (InputStream in = conn.getInputStream(); FileOutputStream out = new FileOutputStream(rsrc.getLocalNew())) { @@ -78,13 +79,13 @@ public class HTTPDownloader extends Downloader // read in the file data int read; - while ((read = in.read(_buffer)) != -1) { + while ((read = in.read(buffer)) != -1) { // abort the download if the downloader is aborted if (_state == State.ABORTED) { break; } // write it out to our local copy - out.write(_buffer, 0, read); + out.write(buffer, 0, read); // note that we've downloaded some data currentSize += read; reportProgress(rsrc, currentSize, actualSize);