Only download as much bytes as advertised.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 21:02:17 +0000 (23:02 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 21:02:17 +0000 (23:02 +0200)
src/main/java/net/pterodactylus/irc/DccReceiver.java

index 038f66a..5c5eac4 100644 (file)
@@ -150,7 +150,7 @@ public class DccReceiver extends AbstractExecutionThreadService {
                        InputStream socketInputStream = socket.getInputStream();
                        inputStream = new BandwidthCountingInputStream(socketInputStream, 5, TimeUnit.SECONDS);
                        byte[] buffer = new byte[65536];
-                       while (isRunning()) {
+                       while (isRunning() && ((size == -1) || (progress < size))) {
                                int r = inputStream.read(buffer);
                                if (r == -1) {
                                        /* yay, eof! */