sgl.normalize() must be called before DownloadContext::setFileFilter() call.

sgl.normalize() was removed from DownloadContext::setFileFilter().
pull/2/head
Tatsuhiro Tsujikawa 2011-10-30 00:51:06 +09:00
parent 9b62a6e1fe
commit d1667ea246
4 changed files with 4 additions and 2 deletions

View File

@ -130,7 +130,6 @@ void DownloadContext::setFilePathWithIndex
void DownloadContext::setFileFilter(SegList<int>& sgl)
{
sgl.normalize();
if(!sgl.hasNext() || fileEntries_.size() == 1) {
std::for_each(fileEntries_.begin(), fileEntries_.end(),
std::bind2nd(mem_fun_sh(&FileEntry::setRequested), true));

View File

@ -179,6 +179,7 @@ public:
ownerRequestGroup_ = owner;
}
// sgl must be normalized before the call.
void setFileFilter(SegList<int>& sgl);
// Sets file path for specified index. index starts from 1. The

View File

@ -186,6 +186,7 @@ createBtRequestGroup(const std::string& torrentFilePath,
}
SegList<int> sgl;
util::parseIntSegments(sgl, option->get(PREF_SELECT_FILE));
sgl.normalize();
dctx->setFileFilter(sgl);
std::istringstream indexOutIn(option->get(PREF_INDEX_OUT));
std::map<size_t, std::string> indexPathMap =

View File

@ -84,7 +84,8 @@ void DownloadContextTest::testSetFileFilter()
}
ctx.setFileEntries(files.begin(), files.end());
SegList<int> sgl;
util::parseIntSegments(sgl, "2-4,6-8");
util::parseIntSegments(sgl, "6-8,2-4");
sgl.normalize();
ctx.setFileFilter(sgl);
const std::vector<SharedHandle<FileEntry> >& res = ctx.getFileEntries();
CPPUNIT_ASSERT(!res[0]->isRequested());