From 86f27fed5761ecd9621f23ea21e5b92769b658c2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 15 May 2009 09:15:07 +0000 Subject: [PATCH] 2009-05-15 Tatsuhiro Tsujikawa Show "[MEMORY]" prefix before filename in download summary if it is downloaded into memory. * src/DownloadResult.h * src/RequestGroup.cc * src/RequestGroupMan.cc --- ChangeLog | 8 ++++++++ src/DownloadResult.h | 4 ++++ src/RequestGroup.cc | 1 + src/RequestGroupMan.cc | 24 +++++++++++++----------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa811182..cd870b80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-05-15 Tatsuhiro Tsujikawa + + Show "[MEMORY]" prefix before filename in download summary if it + is downloaded into memory. + * src/DownloadResult.h + * src/RequestGroup.cc + * src/RequestGroupMan.cc + 2009-05-15 Tatsuhiro Tsujikawa Defined MSG_CANNOT_PARSE_XML_RPC_REQUEST diff --git a/src/DownloadResult.h b/src/DownloadResult.h index 73dd9f7d..973095ee 100644 --- a/src/DownloadResult.h +++ b/src/DownloadResult.h @@ -66,6 +66,8 @@ public: std::deque > fileEntries; + bool inMemoryDownload; + uint64_t totalLength; std::string uri; @@ -81,6 +83,7 @@ public: DownloadResult(int32_t gid, const std::deque >& fileEntries, + bool inMemoryDownload, uint64_t totalLength, const std::string& uri, size_t numUri, @@ -89,6 +92,7 @@ public: RESULT result): gid(gid), fileEntries(fileEntries), + inMemoryDownload(inMemoryDownload), totalLength(totalLength), uri(uri), numUri(numUri), diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 809afc0a..4e07cb37 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -1026,6 +1026,7 @@ DownloadResultHandle RequestGroup::createDownloadResult() const SharedHandle (new DownloadResult(_gid, _downloadContext->getFileEntries(), + _inMemoryDownload, getTotalLength(), uris.empty() ? A2STR::NIL:uris.front(), uris.size(), diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 2fd45f63..57669b7a 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -564,7 +564,7 @@ static size_t countRequestedFileEntry(InputIterator first, InputIterator last) template static void writeFilePath -(InputIterator first, InputIterator last, std::ostream& o) +(InputIterator first, InputIterator last, std::ostream& o, bool memory) { SharedHandle e = getFirstRequestedFileEntry(first, last); if(e.isNull()) { @@ -573,7 +573,11 @@ static void writeFilePath if(e->getPath().empty()) { o << "n/a"; } else { - o << e->getPath(); + if(memory) { + o << "[MEMORY]" << File(e->getPath()).getBasename(); + } else { + o << e->getPath(); + } } size_t count = countRequestedFileEntry(first, last); if(count > 1) { @@ -598,16 +602,14 @@ std::string RequestGroupMan::formatDownloadResult(const std::string& status, con o << "|"; const std::deque >& fileEntries = downloadResult->fileEntries; - if(downloadResult->result == DownloadResult::FINISHED) { - writeFilePath(fileEntries.begin(), fileEntries.end(), o); + if(downloadResult->result == DownloadResult::FINISHED || + downloadResult->numUri == 0) { + writeFilePath(fileEntries.begin(), fileEntries.end(), o, + downloadResult->inMemoryDownload); } else { - if(downloadResult->numUri == 0) { - writeFilePath(fileEntries.begin(), fileEntries.end(), o); - } else { - o << downloadResult->uri; - if(downloadResult->numUri > 1) { - o << " (" << downloadResult->numUri-1 << "more)"; - } + o << downloadResult->uri; + if(downloadResult->numUri > 1) { + o << " (" << downloadResult->numUri-1 << "more)"; } } return o.str();