From ac4652c048ca9edbc8e4b2e0b1a5a8493299b423 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 2 May 2013 21:10:51 +0200 Subject: [PATCH] Send download failed event if we received less bytes than expected. --- src/main/java/net/pterodactylus/irc/DccReceiver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)); -- 2.7.4