From a77d96e2cfd9d7d04087b342487ce77303384844 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 12 Jan 2010 14:30:47 +0000 Subject: [PATCH] 2010-01-12 Tatsuhiro Tsujikawa Added --bt-metadata-only option. If true is given to this option, aria2 downloads metadata only. The file(s) described in metadata will not be downloaded. This option has effect only when BitTorrent Magnet URI is used. See also --bt-save-metadata option. * doc/aria2c.1.txt * src/OptionHandlerFactory.cc * src/UTMetadataPostDownloadHandler.cc * src/download_helper.cc * src/prefs.cc * src/prefs.h * src/usage_text.h --- ChangeLog | 14 ++++++++++++++ doc/aria2c.1 | 29 ++++++++++++++++++++++++---- doc/aria2c.1.html | 22 ++++++++++++++++++--- doc/aria2c.1.txt | 12 ++++++++++-- src/OptionHandlerFactory.cc | 9 +++++++++ src/UTMetadataPostDownloadHandler.cc | 12 +++++++----- src/download_helper.cc | 1 + src/prefs.cc | 2 ++ src/prefs.h | 2 ++ src/usage_text.h | 12 +++++++++--- 10 files changed, 98 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0393031..f378f341 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-01-12 Tatsuhiro Tsujikawa + + Added --bt-metadata-only option. If true is given to this option, + aria2 downloads metadata only. The file(s) described in metadata + will not be downloaded. This option has effect only when + BitTorrent Magnet URI is used. See also --bt-save-metadata option. + * doc/aria2c.1.txt + * src/OptionHandlerFactory.cc + * src/UTMetadataPostDownloadHandler.cc + * src/download_helper.cc + * src/prefs.cc + * src/prefs.h + * src/usage_text.h + 2010-01-12 Tatsuhiro Tsujikawa Fixed memory leak. Commands stored in std::deque are not diff --git a/doc/aria2c.1 b/doc/aria2c.1 index 099760f4..1ec4cf5e 100644 --- a/doc/aria2c.1 +++ b/doc/aria2c.1 @@ -2,12 +2,12 @@ .\" Title: aria2c .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.75.2 -.\" Date: 01/10/2010 +.\" Date: 01/12/2010 .\" Manual: Aria2 Manual .\" Source: Aria2 .\" Language: English .\" -.TH "ARIA2C" "1" "01/10/2010" "Aria2" "Aria2 Manual" +.TH "ARIA2C" "1" "01/12/2010" "Aria2" "Aria2 Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -310,7 +310,7 @@ is set, then authorization header is always sent to the server\&. There is an ex .RS 4 Send Cache\-Control: no\-cache and Pragma: no\-cache header to avoid cached content\&. If \fIfalse\fR -is given , these headers are not sent and you can add Cache\-Control header with a directive you like using +is given, these headers are not sent and you can add Cache\-Control header with a directive you like using \fB\-\-header\fR option\&. Default: \fItrue\fR @@ -519,6 +519,14 @@ option\&. Default: \fI55\fR .RE .PP +\fB\-\-bt\-metadata\-only\fR[=\fItrue\fR|\fIfalse\fR] +.RS 4 +Download metadata only\&. The file(s) described in metadata will not be downloaded\&. This option has effect only when BitTorrent Magnet URI is used\&. See also +\fB\-\-bt\-save\-metadata\fR +option\&. Default: +\fIfalse\fR +.RE +.PP \fB\-\-bt\-min\-crypto\-level\fR=\fIplain\fR|\fIarc4\fR .RS 4 Set minimum level of encryption method\&. If several encryption methods are provided by a peer, aria2 chooses the lowest one which satisfies the given level\&. Default: @@ -555,7 +563,9 @@ or .PP \fB\-\-bt\-save\-metadata\fR[=\fItrue\fR|\fIfalse\fR] .RS 4 -Save metadata as \&.torrent file\&. This option has effect only when BitTorrent Magnet URI is used\&. The filename is hex encoded info hash with suffix \&.torrent\&. The directory to be saved is the same directory where download file is saved\&. If the same file already exists, metadata is not saved\&. Default: +Save metadata as \&.torrent file\&. This option has effect only when BitTorrent Magnet URI is used\&. The filename is hex encoded info hash with suffix \&.torrent\&. The directory to be saved is the same directory where download file is saved\&. If the same file already exists, metadata is not saved\&. See also +\fB\-\-bt\-metadata\-only\fR +option\&. Default: \fIfalse\fR .RE .PP @@ -1739,6 +1749,17 @@ bt\-max\-peers .sp -1 .IP \(bu 2.3 .\} +bt\-metadata\-only +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} bt\-min\-crypto\-level .RE .sp diff --git a/doc/aria2c.1.html b/doc/aria2c.1.html index 6912d5ca..6c80f684 100644 --- a/doc/aria2c.1.html +++ b/doc/aria2c.1.html @@ -929,7 +929,7 @@ aria2c -o myfile.zip "http://mirror1/file.zip" "http://mirror2/file.zip"

Send Cache-Control: no-cache and Pragma: no-cache header to avoid - cached content. If false is given , these headers are not sent + cached content. If false is given, these headers are not sent and you can add Cache-Control header with a directive you like using --header option. Default: true

@@ -1213,6 +1213,16 @@ writes the piece to the appropriate files.

+--bt-metadata-only[=true|false] +
+
+

+ Download metadata only. The file(s) described in metadata will not + be downloaded. This option has effect only when BitTorrent Magnet + URI is used. See also --bt-save-metadata option. Default: false +

+
+
--bt-min-crypto-level=plain|arc4
@@ -1271,7 +1281,8 @@ writes the piece to the appropriate files. BitTorrent Magnet URI is used. The filename is hex encoded info hash with suffix .torrent. The directory to be saved is the same directory where download file is saved. If the same file already - exists, metadata is not saved. Default: false + exists, metadata is not saved. See also --bt-metadata-only + option. Default: false

@@ -2399,6 +2410,11 @@ bt-max-peers
  • +bt-metadata-only +

    +
  • +
  • +

    bt-min-crypto-level

  • @@ -3562,7 +3578,7 @@ files in the program, then also delete it here.


    diff --git a/doc/aria2c.1.txt b/doc/aria2c.1.txt index 8e9a3274..2807f582 100644 --- a/doc/aria2c.1.txt +++ b/doc/aria2c.1.txt @@ -216,7 +216,7 @@ HTTP Specific Options *--http-no-cache*[='true'|'false']:: Send Cache-Control: no-cache and Pragma: no-cache header to avoid - cached content. If 'false' is given , these headers are not sent + cached content. If 'false' is given, these headers are not sent and you can add Cache-Control header with a directive you like using *--header* option. Default: 'true' @@ -358,6 +358,12 @@ BitTorrent Specific Options unlimited. See also *--bt-request-peer-speed-limit* option. Default: '55' +*--bt-metadata-only*[='true'|'false']:: + + Download metadata only. The file(s) described in metadata will not + be downloaded. This option has effect only when BitTorrent Magnet + URI is used. See also *--bt-save-metadata* option. Default: 'false' + *--bt-min-crypto-level*='plain'|'arc4':: Set minimum level of encryption method. If several encryption methods are provided by a peer, aria2 chooses the lowest @@ -395,7 +401,8 @@ BitTorrent Specific Options BitTorrent Magnet URI is used. The filename is hex encoded info hash with suffix .torrent. The directory to be saved is the same directory where download file is saved. If the same file already - exists, metadata is not saved. Default: 'false' + exists, metadata is not saved. See also *--bt-metadata-only* + option. Default: 'false' *--bt-seed-unverified*[='true'|'false']:: Seed previously downloaded files without verifying piece hashes. @@ -996,6 +1003,7 @@ of URIs. These optional lines must start with white space(s). * bt-hash-check-seed * bt-max-open-files * bt-max-peers +* bt-metadata-only * bt-min-crypto-level * bt-prioritize-piece * bt-require-crypto diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 71fb8e0c..1ef10d0f 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -979,6 +979,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() handlers.push_back(op); } + { + SharedHandle op(new BooleanOptionHandler + (PREF_BT_METADATA_ONLY, + TEXT_BT_METADATA_ONLY, + V_FALSE, + OptionHandler::OPT_ARG)); + op->addTag(TAG_BITTORRENT); + handlers.push_back(op); + } { SharedHandle op(new ParameterOptionHandler (PREF_BT_MIN_CRYPTO_LEVEL, diff --git a/src/UTMetadataPostDownloadHandler.cc b/src/UTMetadataPostDownloadHandler.cc index d3230ad2..ea07b602 100644 --- a/src/UTMetadataPostDownloadHandler.cc +++ b/src/UTMetadataPostDownloadHandler.cc @@ -92,12 +92,14 @@ void UTMetadataPostDownloadHandler::getNextRequestGroups _logger->notice(MSG_METADATA_NOT_SAVED, filename.c_str()); } } - std::deque > newRgs; - createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(), - std::deque(), torrent); + if(!requestGroup->getOption()->getAsBool(PREF_BT_METADATA_ONLY)) { + std::deque > newRgs; + createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(), + std::deque(), torrent); - requestGroup->followedBy(newRgs.begin(), newRgs.end()); - groups.insert(groups.end(), newRgs.begin(), newRgs.end()); + requestGroup->followedBy(newRgs.begin(), newRgs.end()); + groups.insert(groups.end(), newRgs.begin(), newRgs.end()); + } } } // namespace aria2 diff --git a/src/download_helper.cc b/src/download_helper.cc index bbec38fd..86e2e7ae 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -112,6 +112,7 @@ const std::set& listRequestOptions() PREF_BT_HASH_CHECK_SEED, PREF_BT_MAX_OPEN_FILES, PREF_BT_MAX_PEERS, + PREF_BT_METADATA_ONLY, PREF_BT_MIN_CRYPTO_LEVEL, PREF_BT_PRIORITIZE_PIECE, PREF_BT_REQUIRE_CRYPTO, diff --git a/src/prefs.cc b/src/prefs.cc index 321ac8f0..554783df 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -312,6 +312,8 @@ const std::string PREF_BT_STOP_TIMEOUT("bt-stop-timeout"); const std::string PREF_BT_PRIORITIZE_PIECE("bt-prioritize-piece"); // values: true | false const std::string PREF_BT_SAVE_METADATA("bt-save-metadata"); +// values: true | false +const std::string PREF_BT_METADATA_ONLY("bt-metadata-only"); /** * Metalink related preferences diff --git a/src/prefs.h b/src/prefs.h index 68d1d9c5..f0a97119 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -316,6 +316,8 @@ extern const std::string PREF_BT_STOP_TIMEOUT; extern const std::string PREF_BT_PRIORITIZE_PIECE; // values: true | false extern const std::string PREF_BT_SAVE_METADATA; +// values: true | false +extern const std::string PREF_BT_METADATA_ONLY; /** * Metalink related preferences diff --git a/src/usage_text.h b/src/usage_text.h index 0f94509e..eebcb625 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -589,10 +589,16 @@ " The filename is hex encoded info hash with suffix\n" \ " .torrent. The directory to be saved is the same\n" \ " directory where download file is saved. If the\n" \ - " same file already exists, metadata is not saved.") + " same file already exists, metadata is not saved.\n" \ + " See also --bt-metadata-only option.") #define TEXT_HTTP_NO_CACHE \ _(" --http-no-cache[=true|false] Send Cache-Control: no-cache and Pragma: no-cache\n" \ - " header to avoid cached content. If false is given\n" \ - " , these headers are not sent and you can add\n" \ + " header to avoid cached content. If false is\n" \ + " given, these headers are not sent and you can add\n" \ " Cache-Control header with a directive you like\n" \ " using --header option.") +#define TEXT_BT_METADATA_ONLY \ + _(" --bt-metadata-only[=true|false] Download metadata only. The file(s) described\n" \ + " in metadata will not be downloaded. This option\n" \ + " has effect only when BitTorrent Magnet URI is\n" \ + " used. See also --bt-save-metadata option.")