Allow cancelling a download even if network is gone
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 6 Mar 2015 05:59:52 +0000 (06:59 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 6 Mar 2015 05:59:52 +0000 (06:59 +0100)
src/main/java/net/pterodactylus/xdcc/core/Core.java

index 5b1b12d..24727d9 100644 (file)
@@ -339,13 +339,6 @@ public class Core extends AbstractExecutionThreadService {
                        return;
                }
 
-               /* get connection. */
-               Connection connection = networkConnections.get(bot.network());
-               if (connection == null) {
-                       /* request for unknown network? */
-                       return;
-               }
-
                /* stop the DCC receiver. */
                if (download.get().dccReceiver() != null) {
                        download.get().dccReceiver().stop();
@@ -354,6 +347,13 @@ public class Core extends AbstractExecutionThreadService {
                        downloads.remove(pack.name(), download.get());
                }
 
+               /* get connection. */
+               Connection connection = networkConnections.get(bot.network());
+               if (connection == null) {
+                       /* request for unknown network? */
+                       return;
+               }
+
                /* remove the request from the bot, too. */
                try {
                        connection.sendMessage(bot.name(), String.format("XDCC %s", (download.get().dccReceiver() != null) ? "CANCEL" : "REMOVE"));