summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-09-27 21:48:41 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-09-27 21:48:41 +0900
commit7e7aeac3ff12ecac15995c83cf51e66338d64447 (patch)
tree4ac0eefe41e1c3712322f3997f4b21c79fecae8b /src
parent05104ba177d792b74c6455516e063c4d9a5a8ebd (diff)
Added --piece-length option.
This option sets a piece length for HTTP/FTP downloads. This is the boundary when aria2 splits a file. All splits occur at multiple of this length. This option will be ignored in BitTorrent downloads. It will be also ignored if Metalink file contains piece hashes.
Diffstat (limited to 'src')
-rw-r--r--src/Metalink2RequestGroup.cc6
-rw-r--r--src/OptionHandlerFactory.cc21
-rw-r--r--src/TrackerWatcherCommand.cc2
-rw-r--r--src/download_helper.cc5
-rw-r--r--src/prefs.cc2
-rw-r--r--src/prefs.h2
-rw-r--r--src/usage_text.h7
7 files changed, 28 insertions, 17 deletions
diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc
index 07291dda..21f1f289 100644
--- a/src/Metalink2RequestGroup.cc
+++ b/src/Metalink2RequestGroup.cc
@@ -243,12 +243,12 @@ Metalink2RequestGroup::createRequestGroup
size_t pieceLength;
#ifdef ENABLE_MESSAGE_DIGEST
if(!entry->chunkChecksum) {
- pieceLength = option->getAsInt(PREF_SEGMENT_SIZE);
+ pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
} else {
pieceLength = entry->chunkChecksum->getPieceLength();
}
#else
- pieceLength = option->getAsInt(PREF_SEGMENT_SIZE);
+ pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
#endif // ENABLE_MESSAGE_DIGEST
dctx.reset(new DownloadContext
(pieceLength,
@@ -281,7 +281,7 @@ Metalink2RequestGroup::createRequestGroup
} else {
dctx.reset(new DownloadContext());
// piece length is overridden by the one in torrent file.
- dctx->setPieceLength(option->getAsInt(PREF_SEGMENT_SIZE));
+ dctx->setPieceLength(option->getAsInt(PREF_PIECE_LENGTH));
std::vector<SharedHandle<FileEntry> > fileEntries;
off_t offset = 0;
for(std::vector<SharedHandle<MetalinkEntry> >::const_iterator i =
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index 59636c52..596db314 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -763,6 +763,18 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op);
}
{
+ SharedHandle<UnitNumberOptionHandler> op(new UnitNumberOptionHandler
+ (PREF_PIECE_LENGTH,
+ TEXT_PIECE_LENGTH,
+ "1M",
+ 1024*1024,
+ 1024*1024*1024));
+ op->addTag(TAG_ADVANCED);
+ op->addTag(TAG_FTP);
+ op->addTag(TAG_HTTP);
+ handlers.push_back(op);
+ }
+ {
SharedHandle<OptionHandler> op(new BooleanOptionHandler
(PREF_REMOTE_TIME,
TEXT_REMOTE_TIME,
@@ -794,15 +806,6 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op);
}
{
- SharedHandle<UnitNumberOptionHandler> op(new UnitNumberOptionHandler
- (PREF_SEGMENT_SIZE,
- NO_DESCRIPTION,
- "1M",
- 1024, -1));
- op->hide();
- handlers.push_back(op);
- }
- {
SharedHandle<OptionHandler> op(new DefaultOptionHandler
(PREF_SERVER_STAT_IF,
TEXT_SERVER_STAT_IF,
diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc
index d486aa5a..fd4f3465 100644
--- a/src/TrackerWatcherCommand.cc
+++ b/src/TrackerWatcherCommand.cc
@@ -236,7 +236,7 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
rg->getOption()->put(PREF_SELECT_LEAST_USED_HOST, A2_V_FALSE);
static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]");
SharedHandle<DownloadContext> dctx
- (new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE),
+ (new DownloadContext(getOption()->getAsInt(PREF_PIECE_LENGTH),
0,
TRACKER_ANNOUNCE_FILE));
dctx->getFileEntries().front()->setUris(uris);
diff --git a/src/download_helper.cc b/src/download_helper.cc
index 1c523809..8201ac58 100644
--- a/src/download_helper.cc
+++ b/src/download_helper.cc
@@ -170,7 +170,8 @@ const std::set<std::string>& listRequestOptions()
PREF_PAUSE,
PREF_STREAM_PIECE_SELECTOR,
PREF_HASH_CHECK_ONLY,
- PREF_CHECKSUM
+ PREF_CHECKSUM,
+ PREF_PIECE_LENGTH
};
static std::set<std::string> requestOptions
(vbegin(REQUEST_OPTIONS), vend(REQUEST_OPTIONS));
@@ -223,7 +224,7 @@ SharedHandle<RequestGroup> createRequestGroup
SharedHandle<RequestGroup> rg(new RequestGroup(option));
SharedHandle<DownloadContext> dctx
(new DownloadContext
- (option->getAsInt(PREF_SEGMENT_SIZE),
+ (option->getAsInt(PREF_PIECE_LENGTH),
0,
useOutOption&&!option->blank(PREF_OUT)?
util::applyDir(option->get(PREF_DIR), option->get(PREF_OUT)):A2STR::NIL));
diff --git a/src/prefs.cc b/src/prefs.cc
index 9a4ba8a6..4080ceea 100644
--- a/src/prefs.cc
+++ b/src/prefs.cc
@@ -76,7 +76,7 @@ const std::string PREF_REFERER("referer");
// value: 1*digit
const std::string PREF_LOWEST_SPEED_LIMIT("lowest-speed-limit");
// value: 1*digit
-const std::string PREF_SEGMENT_SIZE("segment-size");
+const std::string PREF_PIECE_LENGTH("piece-length");
// value: 1*digit
const std::string PREF_MAX_OVERALL_DOWNLOAD_LIMIT("max-overall-download-limit");
// value: 1*digit
diff --git a/src/prefs.h b/src/prefs.h
index 802e4916..37de2a68 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -80,7 +80,7 @@ extern const std::string PREF_REFERER;
// value: 1*digit
extern const std::string PREF_LOWEST_SPEED_LIMIT;
// value: 1*digit
-extern const std::string PREF_SEGMENT_SIZE;
+extern const std::string PREF_PIECE_LENGTH;
// value: 1*digit
extern const std::string PREF_MAX_DOWNLOAD_LIMIT;
// value: 1*digit
diff --git a/src/usage_text.h b/src/usage_text.h
index 90e54865..6698130a 100644
--- a/src/usage_text.h
+++ b/src/usage_text.h
@@ -847,3 +847,10 @@
" sha-1=0192ba11326fe2298c8cb4de616f4d4140213838\n" \
" This option applies only to HTTP(S)/FTP\n" \
" downloads.")
+#define TEXT_PIECE_LENGTH \
+ _(" --piece-length=LENGTH Set a piece length for HTTP/FTP downloads. This\n" \
+ " is the boundary when aria2 splits a file. All\n" \
+ " splits occur at multiple of this length. This\n" \
+ " option will be ignored in BitTorrent downloads.\n" \
+ " It will be also ignored if Metalink file\n" \
+ " contains piece hashes.")