From 7cf4d960b265bfa56af6c7abda94eaf00233c6c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 15 Jan 2014 06:34:22 +0100 Subject: [PATCH] Remove failed downloads when a download finishes. --- .../java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 56bfd33..e9bcc3c 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.io.BufferedReader; import java.io.IOException; import java.io.Reader; import java.io.Writer; +import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -155,6 +156,7 @@ public class CommandReader extends AbstractExecutionThreadService { @Subscribe public void downloadFinished(DownloadFinished downloadFinished) { Download download = downloadFinished.download(); + removeFailedDownloads(download.pack().name()); try { writeLine(green(String.format("Download of %s (from %s, %s) has finished, at %s/s.", download.pack().name(), download.bot().name(), download.bot().network().name(), f(download.dccReceiver().overallRate())))); } catch (IOException ioe1) { @@ -162,6 +164,16 @@ public class CommandReader extends AbstractExecutionThreadService { } } + private void removeFailedDownloads(String name) { + List failedDownloadsToRemove = new ArrayList<>(); + for (Download failedDownload : failedDownloads) { + if (failedDownload.pack().name().equals(name)) { + failedDownloadsToRemove.add(failedDownload); + } + } + failedDownloads.removeAll(failedDownloadsToRemove); + } + /** * Called when a download fails. * -- 2.7.4