X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Firc%2FDccReceiver.java;h=ed59c690978ec3e5ac3964db4cc9cb634fd1b9c1;hb=ac4652c048ca9edbc8e4b2e0b1a5a8493299b423;hp=9ddca13c7ff75c8e22d78fb6a3c00ae3813ba176;hpb=a3d06abf861a58f14bd4c9c06d33d5b101488858;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/irc/DccReceiver.java b/src/main/java/net/pterodactylus/irc/DccReceiver.java index 9ddca13..ed59c69 100644 --- a/src/main/java/net/pterodactylus/irc/DccReceiver.java +++ b/src/main/java/net/pterodactylus/irc/DccReceiver.java @@ -155,7 +155,7 @@ public class DccReceiver extends AbstractExecutionThreadService { * @return The current rate of the download, in bytes/second */ public long currentRate() { - return inputStream.getCurrentRate(); + return (inputStream != null) ? inputStream.getCurrentRate() : 0; } /** @@ -164,7 +164,7 @@ public class DccReceiver extends AbstractExecutionThreadService { * @return The overall rate of the download, in bytes/second */ public long overallRate() { - return inputStream.getOverallRate(); + return (inputStream != null) ? inputStream.getOverallRate() : 0; } // @@ -189,7 +189,11 @@ public class DccReceiver extends AbstractExecutionThreadService { progress += r; } outputStream.flush(); - eventBus.post(new DccDownloadFinished(this)); + if ((size == -1) || (progress == size)) { + eventBus.post(new DccDownloadFinished(this)); + } else { + eventBus.post(new DccDownloadFailed(this, new IOException("Download aborted."))); + } } catch (IOException ioe1) { logger.log(Level.WARNING, "I/O error while receiving DCC!", ioe1); eventBus.post(new DccDownloadFailed(this, ioe1));