import net.pterodactylus.xdcc.core.event.GenericMessage;
import net.pterodactylus.xdcc.core.event.MessageReceived;
import net.pterodactylus.xdcc.data.Download;
+import net.pterodactylus.xdcc.util.io.DuplicateLineSuppressingWriter;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
/** The writer to write the results to. */
private final Writer writer;
+ private final Collection<Download> failedDownloads;
/**
* Creates a new command reader.
* @param writer
* The write to write results to
*/
- public CommandReader(Core core, Reader reader, Writer writer) {
+ public CommandReader(Core core, Reader reader, Writer writer, Collection<Download> failedDownloads) {
this.reader = new BufferedReader(reader);
- this.writer = writer;
+ this.writer = new DuplicateLineSuppressingWriter(writer);
+ this.failedDownloads = failedDownloads;
/* initialize commands. */
ImmutableList.Builder<Command> commandBuilder = ImmutableList.builder();
commandBuilder.add(new ListConnectionsCommand(core));
commandBuilder.add(new AbortDownloadCommand(core));
commandBuilder.add(new DisconnectCommand(core));
+ commandBuilder.add(new FailedDownloadsCommand(failedDownloads));
+ commandBuilder.add(new RestartCommand(core, failedDownloads));
+ commandBuilder.add(new ResearchCommand(core));
commands = commandBuilder.build();
}
@Subscribe
public void downloadFailed(DownloadFailed downloadFailed) {
Download download = downloadFailed.download();
+ failedDownloads.add(download);
try {
writeLine(red(String.format("Download of %s (from %s, %s) has failed at %.1f%% and %s/s.", download.filename(), download.bot().name(), download.bot().network().name(), download.dccReceiver().progress() * 100.0 / download.dccReceiver().size(), f(download.dccReceiver().overallRate()))));
} catch (IOException ioe1) {