Send download failed event if we received less bytes than expected.
[xudocci.git] / 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));