mirror of https://github.com/aria2/aria2
				
				
				
			2010-02-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that grouped FileEntry objects are not used but instead all FileEntry objects are used for each metaurl group. * src/Metalink2RequestGroup.cc * test/Metalink2RequestGroupTest.cc * test/metalink4-groupbymetaurl.xmlpull/1/head
							parent
							
								
									4bef54c8e9
								
							
						
					
					
						commit
						0c62e90730
					
				| 
						 | 
				
			
			@ -1,3 +1,11 @@
 | 
			
		|||
2010-02-28  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 | 
			
		||||
 | 
			
		||||
	Fixed the bug that grouped FileEntry objects are not used but
 | 
			
		||||
	instead all FileEntry objects are used for each metaurl group.
 | 
			
		||||
	* src/Metalink2RequestGroup.cc
 | 
			
		||||
	* test/Metalink2RequestGroupTest.cc
 | 
			
		||||
	* test/metalink4-groupbymetaurl.xml
 | 
			
		||||
 | 
			
		||||
2010-02-27  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 | 
			
		||||
 | 
			
		||||
	Use vector instead of deque for ChunkChecksum.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -180,7 +180,7 @@ Metalink2RequestGroup::createRequestGroup
 | 
			
		|||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  std::for_each(entries.begin(), entries.end(),
 | 
			
		||||
  std::for_each(selectedEntries.begin(), selectedEntries.end(),
 | 
			
		||||
                mem_fun_sh(&MetalinkEntry::reorderMetaurlsByPriority));
 | 
			
		||||
  std::vector<std::pair<std::string,
 | 
			
		||||
    std::vector<SharedHandle<MetalinkEntry> > > > entryGroups;
 | 
			
		||||
| 
						 | 
				
			
			@ -276,8 +276,8 @@ Metalink2RequestGroup::createRequestGroup
 | 
			
		|||
      dctx->setPieceLength(option->getAsInt(PREF_SEGMENT_SIZE));
 | 
			
		||||
      std::vector<SharedHandle<FileEntry> > fileEntries;
 | 
			
		||||
      off_t offset = 0;
 | 
			
		||||
      for(std::deque<SharedHandle<MetalinkEntry> >::const_iterator i =
 | 
			
		||||
            entries.begin(); i != entries.end(); ++i) {
 | 
			
		||||
      for(std::vector<SharedHandle<MetalinkEntry> >::const_iterator i =
 | 
			
		||||
            mes.begin(); i != mes.end(); ++i) {
 | 
			
		||||
        _logger->info("Metalink: Queueing %s for download as a member.",
 | 
			
		||||
                      (*i)->getPath().c_str());
 | 
			
		||||
        _logger->debug("originalName = %s", (*i)->metaurls[0]->name.c_str());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ class Metalink2RequestGroupTest:public CppUnit::TestFixture {
 | 
			
		|||
 | 
			
		||||
  CPPUNIT_TEST_SUITE(Metalink2RequestGroupTest);
 | 
			
		||||
  CPPUNIT_TEST(testGenerate);
 | 
			
		||||
  CPPUNIT_TEST(testGenerate_groupByMetaurl);
 | 
			
		||||
  CPPUNIT_TEST_SUITE_END();
 | 
			
		||||
private:
 | 
			
		||||
  SharedHandle<Option> _option;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,6 +29,7 @@ public:
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  void testGenerate();
 | 
			
		||||
  void testGenerate_groupByMetaurl();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -121,4 +123,50 @@ void Metalink2RequestGroupTest::testGenerate()
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Metalink2RequestGroupTest::testGenerate_groupByMetaurl()
 | 
			
		||||
{
 | 
			
		||||
  std::deque<SharedHandle<RequestGroup> > groups;
 | 
			
		||||
  Metalink2RequestGroup().generate(groups, "metalink4-groupbymetaurl.xml",
 | 
			
		||||
                                   _option);
 | 
			
		||||
  CPPUNIT_ASSERT_EQUAL((size_t)3, groups.size());
 | 
			
		||||
  // first RequestGroup is torrent for second RequestGroup
 | 
			
		||||
  {
 | 
			
		||||
    SharedHandle<RequestGroup> rg = groups[0];
 | 
			
		||||
    std::deque<std::string> uris;
 | 
			
		||||
    rg->getDownloadContext()->getFirstFileEntry()->getUris(uris);
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL((size_t)1, uris.size());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("http://torrent"), uris[0]);
 | 
			
		||||
  }
 | 
			
		||||
  // second
 | 
			
		||||
  {
 | 
			
		||||
    SharedHandle<RequestGroup> rg = groups[1];
 | 
			
		||||
    SharedHandle<DownloadContext> dctx = rg->getDownloadContext();
 | 
			
		||||
    const std::vector<SharedHandle<FileEntry> >& fileEntries =
 | 
			
		||||
      dctx->getFileEntries();
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntries.size());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("./file1"), fileEntries[0]->getPath());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("file1"), fileEntries[0]->getOriginalName());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries[0]->getRemainingUris().size());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("http://file1p1"),
 | 
			
		||||
                         fileEntries[0]->getRemainingUris()[0]);
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("./file3"), fileEntries[1]->getPath());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("file3"), fileEntries[1]->getOriginalName());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries[1]->getRemainingUris().size());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("http://file3p1"),
 | 
			
		||||
                         fileEntries[1]->getRemainingUris()[0]);
 | 
			
		||||
  }
 | 
			
		||||
  // third
 | 
			
		||||
  {
 | 
			
		||||
    SharedHandle<RequestGroup> rg = groups[2];
 | 
			
		||||
    SharedHandle<DownloadContext> dctx = rg->getDownloadContext();
 | 
			
		||||
    const std::vector<SharedHandle<FileEntry> >& fileEntries =
 | 
			
		||||
      dctx->getFileEntries();
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries.size());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("./file2"), fileEntries[0]->getPath());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntries[0]->getRemainingUris().size());
 | 
			
		||||
    CPPUNIT_ASSERT_EQUAL(std::string("http://file2p1"),
 | 
			
		||||
                         fileEntries[0]->getRemainingUris()[0]);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace aria2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<metalink xmlns="urn:ietf:params:xml:ns:metalink">
 | 
			
		||||
  <file name="file1">
 | 
			
		||||
    <size>1000</size>
 | 
			
		||||
    <url priority="1">http://file1p1</url>
 | 
			
		||||
    <metaurl mediatype="torrent" priority="1" name="file1">http://torrent</metaurl>
 | 
			
		||||
  </file>
 | 
			
		||||
  <file name="file2">
 | 
			
		||||
    <size>2000</size>
 | 
			
		||||
    <url priority="1">http://file2p1</url>
 | 
			
		||||
  </file>
 | 
			
		||||
  <file name="file3">
 | 
			
		||||
    <size>3000</size>
 | 
			
		||||
    <url priority="1">http://file3p1</url>
 | 
			
		||||
    <metaurl mediatype="torrent" priority="1" name="file3">http://torrent</metaurl>
 | 
			
		||||
  </file>
 | 
			
		||||
</metalink>
 | 
			
		||||
		Loading…
	
		Reference in New Issue