ソースを参照

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

sgl.normalize() was removed from DownloadContext::setFileFilter().
Tatsuhiro Tsujikawa 14 年 前
コミット
d1667ea246
4 ファイル変更4 行追加2 行削除
  1. 0 1
      src/DownloadContext.cc
  2. 1 0
      src/DownloadContext.h
  3. 1 0
      src/download_helper.cc
  4. 2 1
      test/DownloadContextTest.cc

+ 0 - 1
src/DownloadContext.cc

@@ -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));

+ 1 - 0
src/DownloadContext.h

@@ -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

+ 1 - 0
src/download_helper.cc

@@ -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 =

+ 2 - 1
test/DownloadContextTest.cc

@@ -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());