Add --pause-metadata option

This option pauses downloads created as a result of metadata
download. There are 3 types of metadata downloads in aria2: (1)
downloading .torrent file. (2) downloading torrent metadata using
magnet link. (3) downloading metalink file.  These metadata downloads
will generate downloads using their metadata. This option pauses these
subsequent downloads.
pull/242/head
Tatsuhiro Tsujikawa 2014-06-21 00:24:54 +09:00
parent 2b02fac2d5
commit e2932608fc
8 changed files with 62 additions and 0 deletions

View File

@ -232,6 +232,7 @@ OptionParser.new do |opt|
opt.on("--server-stat-of FILE"){|val| options["server-stat-of"]=val}
opt.on("--save-cookies FILE"){|val| options["save-cookies"]=val}
opt.on("--gid GID"){|val| options["gid"]=val}
opt.on("--pause-metadata [BOOL]",["true","false"]){|val| options["pause-metadata"]=val||"true"}
opt.on("--server SERVER", "hostname of XML-RPC server. Default: localhost"){|val| options["server"]=val }
opt.on("--port PORT", "port of XML-RPC server. Default: 6800"){|val| options["port"]=val }

View File

@ -52,6 +52,7 @@
#include "DiskWriter.h"
#include "AbstractSingleDiskAdaptor.h"
#include "BencodeDiskWriter.h"
#include "RequestGroupMan.h"
namespace aria2 {
@ -108,6 +109,16 @@ void BtPostDownloadHandler::getNextRequestGroups
if(mi) {
setMetadataInfo(newRgs.begin(), newRgs.end(), mi);
}
auto rgman = requestGroup->getRequestGroupMan();
if(rgman && rgman->getKeepRunning() &&
requestGroup->getOption()->getAsBool(PREF_PAUSE_METADATA)) {
for(auto& rg : newRgs) {
rg->setPauseRequested(true);
}
}
groups.insert(groups.end(), newRgs.begin(), newRgs.end());
}

View File

@ -51,6 +51,7 @@
#include "download_helper.h"
#include "fmt.h"
#include "FileEntry.h"
#include "RequestGroupMan.h"
namespace aria2 {
@ -105,6 +106,16 @@ void MetalinkPostDownloadHandler::getNextRequestGroups
if(mi) {
setMetadataInfo(newRgs.begin(), newRgs.end(), mi);
}
auto rgman = requestGroup->getRequestGroupMan();
if(rgman && rgman->getKeepRunning() &&
requestGroup->getOption()->getAsBool(PREF_PAUSE_METADATA)) {
for(auto& rg : newRgs) {
rg->setPauseRequested(true);
}
}
groups.insert(groups.end(), newRgs.begin(), newRgs.end());
diskAdaptor->closeFile();
} catch(Exception& e) {

View File

@ -679,6 +679,19 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setInitialOption(true);
handlers.push_back(op);
}
{
OptionHandler* op(new BooleanOptionHandler
(PREF_PAUSE_METADATA,
TEXT_PAUSE_METADATA,
A2_V_FALSE,
OptionHandler::OPT_ARG));
op->addTag(TAG_ADVANCED);
op->addTag(TAG_RPC);
op->setInitialOption(true);
op->setChangeGlobalOption(true);
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
{
OptionHandler* op(new BooleanOptionHandler
(PREF_QUIET,

View File

@ -50,6 +50,7 @@
#include "prefs.h"
#include "Option.h"
#include "fmt.h"
#include "RequestGroupMan.h"
namespace aria2 {
@ -107,6 +108,16 @@ void UTMetadataPostDownloadHandler::getNextRequestGroups
setMetadataInfo(newRgs.begin(), newRgs.end(),
requestGroup->getMetadataInfo());
}
auto rgman = requestGroup->getRequestGroupMan();
if(rgman && rgman->getKeepRunning() &&
requestGroup->getOption()->getAsBool(PREF_PAUSE_METADATA)) {
for(auto& rg : newRgs) {
rg->setPauseRequested(true);
}
}
groups.insert(groups.end(), newRgs.begin(), newRgs.end());
}
}

View File

@ -363,6 +363,8 @@ PrefPtr PREF_ENABLE_COLOR = makePref("enable-color");
PrefPtr PREF_RPC_SECRET = makePref("rpc-secret");
// values: 1*digit
PrefPtr PREF_DSCP = makePref("dscp");
// values: true | false
PrefPtr PREF_PAUSE_METADATA = makePref("pause-metadata");
/**
* FTP related preferences

View File

@ -300,6 +300,8 @@ extern PrefPtr PREF_ENABLE_COLOR;
extern PrefPtr PREF_RPC_SECRET;
// values: 1*digit
extern PrefPtr PREF_DSCP;
// values: true | false
extern PrefPtr PREF_PAUSE_METADATA;
/**
* FTP related preferences

View File

@ -980,3 +980,14 @@
" commonly used values from RFC, network vendors'\n" \
" documentation, Wikipedia or any other source,\n" \
" use them as they are.")
#define TEXT_PAUSE_METADATA \
_(" --pause-metadata[=true|false]\n" \
" Pause downloads created as a result of metadata\n" \
" download. There are 3 types of metadata\n" \
" downloads in aria2: (1) downloading .torrent\n" \
" file. (2) downloading torrent metadata using\n" \
" magnet link. (3) downloading metalink file.\n" \
" These metadata downloads will generate downloads\n" \
" using their metadata. This option pauses these\n" \
" subsequent downloads. This option is effective\n" \
" only when --enable-rpc=true is given.")