2009-05-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Show "[MEMORY]" prefix before filename in download summary if it
	is downloaded into memory.
	* src/DownloadResult.h
	* src/RequestGroup.cc
	* src/RequestGroupMan.cc
pull/1/head
Tatsuhiro Tsujikawa 2009-05-15 09:15:07 +00:00
parent ee75995198
commit 86f27fed57
4 changed files with 26 additions and 11 deletions

View File

@ -1,3 +1,11 @@
2009-05-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
Defined MSG_CANNOT_PARSE_XML_RPC_REQUEST

View File

@ -66,6 +66,8 @@ public:
std::deque<SharedHandle<FileEntry> > fileEntries;
bool inMemoryDownload;
uint64_t totalLength;
std::string uri;
@ -81,6 +83,7 @@ public:
DownloadResult(int32_t gid,
const std::deque<SharedHandle<FileEntry> >& 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),

View File

@ -1026,6 +1026,7 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
SharedHandle<DownloadResult>
(new DownloadResult(_gid,
_downloadContext->getFileEntries(),
_inMemoryDownload,
getTotalLength(),
uris.empty() ? A2STR::NIL:uris.front(),
uris.size(),

View File

@ -564,7 +564,7 @@ static size_t countRequestedFileEntry(InputIterator first, InputIterator last)
template<typename InputIterator>
static void writeFilePath
(InputIterator first, InputIterator last, std::ostream& o)
(InputIterator first, InputIterator last, std::ostream& o, bool memory)
{
SharedHandle<FileEntry> 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<SharedHandle<FileEntry> >& 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();