List<FrostDownloadItem> frostDownloadItemList = new LinkedList<FrostDownloadItem>();
HashMap<String, FrostDownloadItem> frostDownloadItemKeyMap = new HashMap<String, FrostDownloadItem>();
HashMap<String, FrostDownloadItem> frostDownloadItemNameMap = new HashMap<String, FrostDownloadItem>();
while (it.hasNext()) {
final FileAttachment fa = it.next();
if( frostDownloadItemKeyMap.containsKey(fa.getKey())) {
continue;
}
String filename = fa.getFileName();
// maybe convert html codes (e.g. %2c -> , )
if( filename.indexOf("%") > 0 ) {
try {
filename = java.net.URLDecoder.decode(filename, "UTF-8");
} catch (final java.io.UnsupportedEncodingException ex) {
logger.log(Level.SEVERE, "Decode of HTML code failed", ex);
}
}
if( frostDownloadItemNameMap.containsKey(filename)) {
continue;
}
final FrostDownloadItem frostDwonloadItem = new FrostDownloadItem(
filename,
fa.getKey(),
fa.getFileSize()
);
frostDwonloadItem.setAssociatedMessageId(selectedMessage.getMessageId());
frostDwonloadItem.setAssociatedBoardName(selectedMessage.getBoard().getBoardFilename());
if( Core.frostSettings.getBoolValue(SettingsClass.USE_BOARDNAME_DOWNLOAD_SUBFOLDER_ENABLED) ){
frostDwonloadItem.setDownloadDir(frostDwonloadItem.getDownloadDir().concat(frostDwonloadItem.getAssociatedBoardName()));
}
frostDownloadItemList.add( frostDwonloadItem );
frostDownloadItemKeyMap.put(fa.getKey(), frostDwonloadItem);
frostDownloadItemNameMap.put(filename, frostDwonloadItem);
}
frostDownloadItemKeyMap.clear();
frostDownloadItemNameMap.clear();