Add --bt-enable-hook-after-hash-check option

This option sets flag which allows hook command invocation after hash
check (see -V option) in BitTorrent download.  By default, when hash
check succeeds, the command given by --on-bt-download-complete is
executed.  To disable this action, give false to this option.
pull/498/head
Tatsuhiro Tsujikawa 2015-11-29 18:54:19 +09:00
parent 6a0638c158
commit 35f08f05ef
6 changed files with 39 additions and 3 deletions

View File

@ -639,6 +639,14 @@ BitTorrent Specific Options
queue gets started. But be aware that seeding item is still queue gets started. But be aware that seeding item is still
recognized as active download in RPC method. Default: ``false`` recognized as active download in RPC method. Default: ``false``
.. option:: --bt-enable-hook-after-hash-check[=true|false]
Allow hook command invocation after hash check (see :option:`-V`
option) in BitTorrent download. By default, when hash check
succeeds, the command given by :option:`--on-bt-download-complete`
is executed. To disable this action, give ``false`` to this option.
Default: ``true``
.. option:: --bt-enable-lpd[=true|false] .. option:: --bt-enable-lpd[=true|false]
Enable Local Peer Discovery. If a private flag is set in a torrent, Enable Local Peer Discovery. If a private flag is set in a torrent,
@ -1967,6 +1975,7 @@ of URIs. These optional lines must start with white space(s).
* :option:`always-resume <--always-resume>` * :option:`always-resume <--always-resume>`
* :option:`async-dns <--async-dns>` * :option:`async-dns <--async-dns>`
* :option:`auto-file-renaming <--auto-file-renaming>` * :option:`auto-file-renaming <--auto-file-renaming>`
* :option:`bt-enable-hook-after-hash-check <--bt-enable-hook-after-hash-check>`
* :option:`bt-enable-lpd <--bt-enable-lpd>` * :option:`bt-enable-lpd <--bt-enable-lpd>`
* :option:`bt-exclude-tracker <--bt-exclude-tracker>` * :option:`bt-exclude-tracker <--bt-exclude-tracker>`
* :option:`bt-external-ip <--bt-external-ip>` * :option:`bt-external-ip <--bt-external-ip>`

View File

@ -77,9 +77,12 @@ void BtCheckIntegrityEntry::onDownloadFinished
{ {
auto group = getRequestGroup(); auto group = getRequestGroup();
const auto& option = group->getOption(); const auto& option = group->getOption();
util::executeHookByOptName(group, option.get(), PREF_ON_BT_DOWNLOAD_COMPLETE); if(option->getAsBool(PREF_BT_ENABLE_HOOK_AFTER_HASH_CHECK)) {
util::executeHookByOptName(group, option.get(),
PREF_ON_BT_DOWNLOAD_COMPLETE);
SingletonHolder<Notifier>::instance()->notifyDownloadEvent SingletonHolder<Notifier>::instance()->notifyDownloadEvent
(EVENT_ON_BT_DOWNLOAD_COMPLETE, group); (EVENT_ON_BT_DOWNLOAD_COMPLETE, group);
}
// TODO Currently,when all the checksums // TODO Currently,when all the checksums
// are valid, then aria2 goes to seeding mode. Sometimes it is better // are valid, then aria2 goes to seeding mode. Sometimes it is better
// to exit rather than doing seeding. So, it would be good to toggle this // to exit rather than doing seeding. So, it would be good to toggle this

View File

@ -1749,6 +1749,18 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_BITTORRENT); op->addTag(TAG_BITTORRENT);
handlers.push_back(op); handlers.push_back(op);
} }
{
OptionHandler* op(new BooleanOptionHandler
(PREF_BT_ENABLE_HOOK_AFTER_HASH_CHECK,
TEXT_BT_ENABLE_HOOK_AFTER_HASH_CHECK,
A2_V_TRUE,
OptionHandler::OPT_ARG));
op->addTag(TAG_BITTORRENT);
op->setInitialOption(true);
op->setChangeGlobalOption(true);
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
{ {
OptionHandler* op(new BooleanOptionHandler OptionHandler* op(new BooleanOptionHandler
(PREF_BT_ENABLE_LPD, (PREF_BT_ENABLE_LPD,

View File

@ -556,6 +556,9 @@ PrefPtr PREF_BT_REMOVE_UNSELECTED_FILE =
makePref("bt-remove-unselected-file"); makePref("bt-remove-unselected-file");
PrefPtr PREF_BT_DETACH_SEED_ONLY = makePref("bt-detach-seed-only"); PrefPtr PREF_BT_DETACH_SEED_ONLY = makePref("bt-detach-seed-only");
PrefPtr PREF_BT_FORCE_ENCRYPTION = makePref("bt-force-encryption"); PrefPtr PREF_BT_FORCE_ENCRYPTION = makePref("bt-force-encryption");
// values: true | false
PrefPtr PREF_BT_ENABLE_HOOK_AFTER_HASH_CHECK =
makePref("bt-enable-hook-after-hash-check");
/** /**
* Metalink related preferences * Metalink related preferences

View File

@ -494,6 +494,8 @@ extern PrefPtr PREF_BT_REMOVE_UNSELECTED_FILE;
extern PrefPtr PREF_BT_DETACH_SEED_ONLY; extern PrefPtr PREF_BT_DETACH_SEED_ONLY;
// values: true | false // values: true | false
extern PrefPtr PREF_BT_FORCE_ENCRYPTION; extern PrefPtr PREF_BT_FORCE_ENCRYPTION;
// values: true | false
extern PrefPtr PREF_BT_ENABLE_HOOK_AFTER_HASH_CHECK;
/** /**
* Metalink related preferences * Metalink related preferences

View File

@ -1046,3 +1046,10 @@
" Specifing 0 will disable this option. This value\n" \ " Specifing 0 will disable this option. This value\n" \
" will be set to socket file descriptor using\n" \ " will be set to socket file descriptor using\n" \
" SO_RCVBUF socket option with setsockopt() call.") " SO_RCVBUF socket option with setsockopt() call.")
#define TEXT_BT_ENABLE_HOOK_AFTER_HASH_CHECK \
_(" --bt-enable-hook-after-hash-check[=true|false] Allow hook command invocation\n" \
" after hash check (see -V option) in BitTorrent\n" \
" download. By default, when hash check succeeds,\n" \
" the command given by --on-bt-download-complete\n" \
" is executed. To disable this action, give false\n" \
" to this option.")