From: David ‘Bombe’ Roden Date: Thu, 11 Apr 2013 19:53:28 +0000 (+0200) Subject: Notify user when a download fails. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e77221f564760b9870463d84e241c04a65126466;p=xudocci.git Notify user when a download fails. --- diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java index c362a9b..b77ac2c 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java @@ -28,6 +28,7 @@ import java.util.Set; import net.pterodactylus.irc.DccReceiver; import net.pterodactylus.xdcc.core.Core; +import net.pterodactylus.xdcc.core.event.DownloadFailed; import net.pterodactylus.xdcc.core.event.DownloadFinished; import net.pterodactylus.xdcc.core.event.DownloadStarted; import net.pterodactylus.xdcc.data.Bot; @@ -193,6 +194,23 @@ public class CommandReader extends AbstractExecutionThreadService { } } + /** + * Called when a download fails. + * + * @param downloadFailed + * The download failed event + */ + @Subscribe + public void downloadFailed(DownloadFailed downloadFailed) { + Download download = downloadFailed.download(); + try { + writer.write(String.format("Download of %s (from %s, %s) has failed at %.1f%% and %s/s.\n", download.filename(), download.bot().name(), download.bot().network().name(), download.dccReceiver().progress() * 100.0 / download.dccReceiver().size(), f(download.dccReceiver().overallRate()))); + writer.flush(); + } catch (IOException ioe1) { + /* ignore. */ + } + } + // // PRIVATE METHODS //