long totalQueuedUploadSize = 0;
boolean added = false;
for(RequestStatus req: reqs) {
if(req instanceof DownloadRequestStatus && !uploads) {
DownloadRequestStatus download = (DownloadRequestStatus)req;
if(download.hasSucceeded()) {
if(download.toTempSpace())
completedDownloadToTemp.add(download);
else // to disk
completedDownloadToDisk.add(download);
} else if(download.hasFinished()) {
FetchExceptionMode failureCode = download.getFailureCode();
String mimeType = download.getMIMEType();
if(mimeType == null && (failureCode == FetchExceptionMode.CONTENT_VALIDATION_UNKNOWN_MIME || failureCode == FetchExceptionMode.CONTENT_VALIDATION_BAD_MIME)) {
Logger.error(this, "MIME type is null but failure code is "+FetchException.getMessage(failureCode)+" for "+download.getIdentifier()+" : "+download.getURI());
mimeType = DefaultMIMETypes.DEFAULT_MIME_TYPE;
}
if(failureCode == FetchExceptionMode.CONTENT_VALIDATION_UNKNOWN_MIME) {
mimeType = ContentFilter.stripMIMEType(mimeType);
LinkedList<DownloadRequestStatus> list = failedUnknownMIMEType.get(mimeType);
if(list == null) {
list = new LinkedList<DownloadRequestStatus>();
failedUnknownMIMEType.put(mimeType, list);
}
list.add(download);
} else if(failureCode == FetchExceptionMode.CONTENT_VALIDATION_BAD_MIME) {
mimeType = ContentFilter.stripMIMEType(mimeType);
FilterMIMEType type = ContentFilter.getMIMEType(mimeType);
LinkedList<DownloadRequestStatus> list;
if(type == null) {
Logger.error(this, "Bad MIME failure code yet MIME is "+mimeType+" which does not have a handler!");
list = failedUnknownMIMEType.get(mimeType);
if(list == null) {
list = new LinkedList<DownloadRequestStatus>();
failedUnknownMIMEType.put(mimeType, list);
}
} else {
list = failedBadMIMEType.get(mimeType);
if(list == null) {
list = new LinkedList<DownloadRequestStatus>();
failedBadMIMEType.put(mimeType, list);
}
}
list.add(download);
} else {
failedDownload.add(download);
}
} else {
short prio = download.getPriority();
if(prio < lowestQueuedPrio)
lowestQueuedPrio = prio;
uncompletedDownload.add(download);
long size = download.getDataSize();
if(size > 0)
totalQueuedDownloadSize += size;
}
added = true;
} else if(req instanceof UploadFileRequestStatus && uploads) {