From d1667ea246d492ab0280624cdcc6a454aff7ba0d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 30 Oct 2011 00:51:06 +0900 Subject: [PATCH] sgl.normalize() must be called before DownloadContext::setFileFilter() call. sgl.normalize() was removed from DownloadContext::setFileFilter(). --- src/DownloadContext.cc | 1 - src/DownloadContext.h | 1 + src/download_helper.cc | 1 + test/DownloadContextTest.cc | 3 ++- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index d2be45da..17cc53e6 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -130,7 +130,6 @@ void DownloadContext::setFilePathWithIndex void DownloadContext::setFileFilter(SegList& sgl) { - sgl.normalize(); if(!sgl.hasNext() || fileEntries_.size() == 1) { std::for_each(fileEntries_.begin(), fileEntries_.end(), std::bind2nd(mem_fun_sh(&FileEntry::setRequested), true)); diff --git a/src/DownloadContext.h b/src/DownloadContext.h index f59ef72e..46c69e69 100644 --- a/src/DownloadContext.h +++ b/src/DownloadContext.h @@ -179,6 +179,7 @@ public: ownerRequestGroup_ = owner; } + // sgl must be normalized before the call. void setFileFilter(SegList& sgl); // Sets file path for specified index. index starts from 1. The diff --git a/src/download_helper.cc b/src/download_helper.cc index 8a71d1a7..c5773ef4 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -186,6 +186,7 @@ createBtRequestGroup(const std::string& torrentFilePath, } SegList sgl; util::parseIntSegments(sgl, option->get(PREF_SELECT_FILE)); + sgl.normalize(); dctx->setFileFilter(sgl); std::istringstream indexOutIn(option->get(PREF_INDEX_OUT)); std::map indexPathMap = diff --git a/test/DownloadContextTest.cc b/test/DownloadContextTest.cc index 92bc74e9..7df00d25 100644 --- a/test/DownloadContextTest.cc +++ b/test/DownloadContextTest.cc @@ -84,7 +84,8 @@ void DownloadContextTest::testSetFileFilter() } ctx.setFileEntries(files.begin(), files.end()); SegList sgl; - util::parseIntSegments(sgl, "2-4,6-8"); + util::parseIntSegments(sgl, "6-8,2-4"); + sgl.normalize(); ctx.setFileFilter(sgl); const std::vector >& res = ctx.getFileEntries(); CPPUNIT_ASSERT(!res[0]->isRequested());