Przeglądaj źródła

2009-12-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Use info hash as a filename when saving BitTorrent metadata.
	* src/UTMetadataPostDownloadHandler.cc
	* test/UTMetadataPostDownloadHandlerTest.cc
Tatsuhiro Tsujikawa 16 lat temu
rodzic
commit
606360779f

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2009-12-27  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Use info hash as a filename when saving BitTorrent metadata.
+	* src/UTMetadataPostDownloadHandler.cc
+	* test/UTMetadataPostDownloadHandlerTest.cc
+
 2009-12-26  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Documented system.multicall XML-RPC method in man page.

+ 2 - 6
src/UTMetadataPostDownloadHandler.cc

@@ -88,14 +88,10 @@ void UTMetadataPostDownloadHandler::getNextRequestGroups
   requestGroup->followedBy(newRgs.begin(), newRgs.end());
   groups.insert(groups.end(), newRgs.begin(), newRgs.end());
 
-  if(!newRgs.empty() &&
-     requestGroup->getOption()->getAsBool(PREF_BT_SAVE_METADATA)) {
-    SharedHandle<DownloadContext> dctx = newRgs.front()->getDownloadContext();
-    assert(dctx->hasAttribute(bittorrent::BITTORRENT));
+  if(requestGroup->getOption()->getAsBool(PREF_BT_SAVE_METADATA)) {
     std::string filename = requestGroup->getOption()->get(PREF_DIR);
     filename += A2STR::SLASH_C;
-    filename +=
-      dctx->getAttribute(bittorrent::BITTORRENT)[bittorrent::NAME].s();
+    filename += util::toHex(attrs[bittorrent::INFO_HASH].s());
     filename += ".torrent";
     if(util::saveAs(filename, torrent)) {
       _logger->notice(MSG_METADATA_SAVED, filename.c_str());

+ 1 - 1
test/UTMetadataPostDownloadHandlerTest.cc

@@ -64,7 +64,7 @@ void UTMetadataPostDownloadHandlerTest::testCanHandle()
 
 void UTMetadataPostDownloadHandlerTest::testGetNextRequestGroups()
 {
-  File trfile("aria2-0.8.2.tar.bz2.torrent");
+  File trfile("cd41c7fdddfd034a15a04d7ff881216e01c4ceaf.torrent");
   if(trfile.exists()) {
     trfile.remove();
   }