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
pull/1/head
Tatsuhiro Tsujikawa 2009-12-27 02:42:43 +00:00
parent 1b3436b5cd
commit 606360779f
3 changed files with 9 additions and 7 deletions

View File

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

View File

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

View File

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