import net.pterodactylus.irc.event.ChannelJoined;
import net.pterodactylus.irc.event.ChannelMessageReceived;
import net.pterodactylus.irc.event.ConnectionEstablished;
+import net.pterodactylus.irc.event.DccDownloadFinished;
import net.pterodactylus.irc.event.DccSendReceived;
import net.pterodactylus.irc.util.MessageCleaner;
import net.pterodactylus.irc.util.RandomNickname;
}
}
+ /**
+ * Closes the output stream of the download and moves the file to the final
+ * location.
+ *
+ * @param dccDownloadFinished
+ * The DCC download finished event
+ */
+ @Subscribe
+ public void dccDownloadFinished(DccDownloadFinished dccDownloadFinished) {
+ Download download = downloads.get(dccDownloadFinished.dccReceiver().filename());
+ if (download == null) {
+ /* probably shouldn’t happen. */
+ return;
+ }
+
+ try {
+ download.outputStream().close();
+ File file = new File(download.filename());
+ file.renameTo(new File(finalDirectory, download.filename()));
+ } catch (IOException ioe1) {
+ /* TODO - handle all the errors. */
+ logger.log(Level.WARNING, String.format("Could not move file %s to directory %s.", download.filename(), finalDirectory), ioe1);
+ }
+ }
+
//
// PRIVATE METHODS
//