|
@@ -538,6 +538,50 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+template<typename InputIterator>
|
|
|
+static SharedHandle<FileEntry> getFirstRequestedFileEntry
|
|
|
+(InputIterator first, InputIterator last)
|
|
|
+{
|
|
|
+ for(; first != last; ++first) {
|
|
|
+ if((*first)->isRequested()) {
|
|
|
+ return *first;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SharedHandle<FileEntry>();
|
|
|
+}
|
|
|
+
|
|
|
+template<typename InputIterator>
|
|
|
+static size_t countRequestedFileEntry(InputIterator first, InputIterator last)
|
|
|
+{
|
|
|
+ size_t count = 0;
|
|
|
+ for(; first != last; ++first) {
|
|
|
+ if((*first)->isRequested()) {
|
|
|
+ ++count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+}
|
|
|
+
|
|
|
+template<typename InputIterator>
|
|
|
+static void writeFilePath
|
|
|
+(InputIterator first, InputIterator last, std::ostream& o)
|
|
|
+{
|
|
|
+ SharedHandle<FileEntry> e = getFirstRequestedFileEntry(first, last);
|
|
|
+ if(e.isNull()) {
|
|
|
+ o << "n/a";
|
|
|
+ } else {
|
|
|
+ if(e->getPath().empty()) {
|
|
|
+ o << "n/a";
|
|
|
+ } else {
|
|
|
+ o << e->getPath();
|
|
|
+ }
|
|
|
+ size_t count = countRequestedFileEntry(first, last);
|
|
|
+ if(count > 1) {
|
|
|
+ o << " (" << count-1 << "more)";
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
std::string RequestGroupMan::formatDownloadResult(const std::string& status, const DownloadResultHandle& downloadResult) const
|
|
|
{
|
|
|
std::stringstream o;
|
|
@@ -552,15 +596,13 @@ std::string RequestGroupMan::formatDownloadResult(const std::string& status, con
|
|
|
o << "n/a";
|
|
|
}
|
|
|
o << "|";
|
|
|
+ const std::deque<SharedHandle<FileEntry> >& fileEntries =
|
|
|
+ downloadResult->fileEntries;
|
|
|
if(downloadResult->result == DownloadResult::FINISHED) {
|
|
|
- o << downloadResult->filePath;
|
|
|
+ writeFilePath(fileEntries.begin(), fileEntries.end(), o);
|
|
|
} else {
|
|
|
if(downloadResult->numUri == 0) {
|
|
|
- if(downloadResult->filePath.empty()) {
|
|
|
- o << "n/a";
|
|
|
- } else {
|
|
|
- o << downloadResult->filePath;
|
|
|
- }
|
|
|
+ writeFilePath(fileEntries.begin(), fileEntries.end(), o);
|
|
|
} else {
|
|
|
o << downloadResult->uri;
|
|
|
if(downloadResult->numUri > 1) {
|