mirror of https://github.com/aria2/aria2
2008-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Instead of creating special filename in createDownloadResult() if inMemoryDownload() is true, now it is done in getFilePath(). * src/RequestGroup.cc * test/RequestGroupTest.ccpull/1/head
parent
690340ef02
commit
7bcf0f48b2
|
@ -1,3 +1,10 @@
|
||||||
|
2008-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Instead of creating special filename in createDownloadResult() if
|
||||||
|
inMemoryDownload() is true, now it is done in getFilePath().
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* test/RequestGroupTest.cc
|
||||||
|
|
||||||
2008-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2008-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Print "[MEMORY]" and filename if a file is not saved in disk and just
|
Print "[MEMORY]" and filename if a file is not saved in disk and just
|
||||||
|
|
|
@ -556,8 +556,9 @@ void RequestGroup::createNextCommand(std::deque<Command*>& commands,
|
||||||
std::string RequestGroup::getFilePath() const
|
std::string RequestGroup::getFilePath() const
|
||||||
{
|
{
|
||||||
assert(!_downloadContext.isNull());
|
assert(!_downloadContext.isNull());
|
||||||
if(_downloadContext.isNull()) {
|
if(inMemoryDownload()) {
|
||||||
return A2STR::NIL;
|
static const std::string DIR_MEMORY("[MEMORY]");
|
||||||
|
return DIR_MEMORY+File(_downloadContext->getActualBasePath()).getBasename();
|
||||||
} else {
|
} else {
|
||||||
return _downloadContext->getActualBasePath();
|
return _downloadContext->getActualBasePath();
|
||||||
}
|
}
|
||||||
|
@ -893,18 +894,10 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
|
||||||
_segmentMan->calculateSessionDownloadLength();
|
_segmentMan->calculateSessionDownloadLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path;
|
|
||||||
if(inMemoryDownload()) {
|
|
||||||
static const std::string DIR_MEMORY("[MEMORY]");
|
|
||||||
path = DIR_MEMORY+File(getFilePath()).getBasename();
|
|
||||||
} else {
|
|
||||||
path = getFilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
SharedHandle<DownloadResult>
|
SharedHandle<DownloadResult>
|
||||||
(new DownloadResult(_gid,
|
(new DownloadResult(_gid,
|
||||||
path,
|
getFilePath(),
|
||||||
getTotalLength(),
|
getTotalLength(),
|
||||||
uris.empty() ? A2STR::NIL:uris.front(),
|
uris.empty() ? A2STR::NIL:uris.front(),
|
||||||
uris.size(),
|
uris.size(),
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
#include "ServerHost.h"
|
#include "ServerHost.h"
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include "SingleFileDownloadContext.h"
|
||||||
|
#include "FileEntry.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -10,6 +14,7 @@ class RequestGroupTest : public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST_SUITE(RequestGroupTest);
|
CPPUNIT_TEST_SUITE(RequestGroupTest);
|
||||||
CPPUNIT_TEST(testRegisterSearchRemove);
|
CPPUNIT_TEST(testRegisterSearchRemove);
|
||||||
CPPUNIT_TEST(testRemoveURIWhoseHostnameIs);
|
CPPUNIT_TEST(testRemoveURIWhoseHostnameIs);
|
||||||
|
CPPUNIT_TEST(testGetFilePath);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -18,6 +23,7 @@ public:
|
||||||
|
|
||||||
void testRegisterSearchRemove();
|
void testRegisterSearchRemove();
|
||||||
void testRemoveURIWhoseHostnameIs();
|
void testRemoveURIWhoseHostnameIs();
|
||||||
|
void testGetFilePath();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,4 +75,22 @@ void RequestGroupTest::testRemoveURIWhoseHostnameIs()
|
||||||
rg.getRemainingUris()[0]);
|
rg.getRemainingUris()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RequestGroupTest::testGetFilePath()
|
||||||
|
{
|
||||||
|
SharedHandle<SingleFileDownloadContext> ctx
|
||||||
|
(new SingleFileDownloadContext(1024, 1024, "myfile"));
|
||||||
|
ctx->setDir("/tmp");
|
||||||
|
Option op;
|
||||||
|
std::deque<std::string> uris;
|
||||||
|
|
||||||
|
RequestGroup group(&op, uris);
|
||||||
|
group.setDownloadContext(ctx);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("/tmp/myfile"), group.getFilePath());
|
||||||
|
|
||||||
|
group.markInMemoryDownload();
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL(std::string("[MEMORY]myfile"), group.getFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
Loading…
Reference in New Issue