return;
}
+ /* check if we are already downloading the file? */
+ if (downloads.containsKey(pack.name())) {
+ Collection<Download> packDownloads = downloads.get(pack.name());
+ Collection<Download> runningDownloads = FluentIterable.from(packDownloads).filter(FILTER_RUNNING).toSet();
+ if (!runningDownloads.isEmpty()) {
+ Download download = runningDownloads.iterator().next();
+ eventBus.post(new GenericMessage(String.format("File %s is already downloading from %s (%s).", pack.name(), download.bot().name(), download.bot().network().name())));
+ return;
+ }
+ StringBuilder bots = new StringBuilder();
+ for (Download download : packDownloads) {
+ if (bots.length() > 0) {
+ bots.append(", ");
+ }
+ bots.append(download.bot().name()).append(" (").append(download.bot().network().name()).append(')');
+ }
+ eventBus.post(new GenericMessage(String.format("File %s is already requested from %d bots (%s).", pack.name(), packDownloads.size(), bots.toString())));
+ }
+
Download download = new Download(bot, pack);
downloads.put(pack.name(), download);