From: David ‘Bombe’ Roden Date: Thu, 2 May 2013 19:10:51 +0000 (+0200) Subject: Send download failed event if we received less bytes than expected. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ac4652c048ca9edbc8e4b2e0b1a5a8493299b423;p=xudocci.git Send download failed event if we received less bytes than expected. --- diff --git a/src/main/java/net/pterodactylus/irc/DccReceiver.java b/src/main/java/net/pterodactylus/irc/DccReceiver.java index be4f145..ed59c69 100644 --- a/src/main/java/net/pterodactylus/irc/DccReceiver.java +++ b/src/main/java/net/pterodactylus/irc/DccReceiver.java @@ -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));