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

Added --bt-save-metadata option. When true is given, it saves
	metadata as .torrent file. This option has effect only when
	BitTorrent Magnet URI is used.  The filename is name in metadata
	with suffix .torrent. The directory to be saved is the same
	directory where download file is saved. If the same file already
	exists, metdata is not saved.
	* src/OptionHandlerFactory.cc
	* src/UTMetadataPostDownloadHandler.cc
	* src/UTMetadataPostDownloadHandler.h
	* src/message.h
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
	* test/UTMetadataDataExtensionMessageTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2009-12-23 13:21:12 +00:00
parent 9b933ca406
commit 2745d85597
9 changed files with 78 additions and 1 deletions

View file

@ -13,6 +13,7 @@
#include "DiskAdaptor.h"
#include "util.h"
#include "MessageDigestHelper.h"
#include "prefs.h"
namespace aria2 {
@ -62,6 +63,10 @@ void UTMetadataPostDownloadHandlerTest::testCanHandle()
void UTMetadataPostDownloadHandlerTest::testGetNextRequestGroups()
{
File trfile("aria2-0.8.2.tar.bz2.torrent");
if(trfile.exists()) {
trfile.remove();
}
std::string metadata =
"d6:lengthi384e4:name19:aria2-0.8.2.tar.bz212:piece lengthi128e"
"6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCe";
@ -104,6 +109,13 @@ void UTMetadataPostDownloadHandlerTest::testGetNextRequestGroups()
(std::find(_requestGroup->followedBy().begin(),
_requestGroup->followedBy().end(),
newRg->getGID()) != _requestGroup->followedBy().end());
CPPUNIT_ASSERT(!trfile.exists());
results.clear();
_requestGroup->getOption()->put(PREF_BT_SAVE_METADATA, V_TRUE);
handler.getNextRequestGroups(results, _requestGroup.get());
CPPUNIT_ASSERT(trfile.exists());
results.clear();