Send download failed event if we received less bytes than expected.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 2 May 2013 19:10:51 +0000 (21:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 2 May 2013 19:10:51 +0000 (21:10 +0200)
src/main/java/net/pterodactylus/irc/DccReceiver.java

index be4f145..ed59c69 100644 (file)
@@ -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));