summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-11-29 18:54:19 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-11-29 18:54:19 +0900
commit35f08f05efcb2c7503abe11af036e8533d5a7b71 (patch)
treeef64a0e85b0874ee1c87a8775d32af7217b337bb /src
parent6a0638c158b3046c6f384267744897fa9d014ab0 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/BtCheckIntegrityEntry.cc9
-rw-r--r--src/OptionHandlerFactory.cc12
-rw-r--r--src/prefs.cc3
-rw-r--r--src/prefs.h2
-rw-r--r--src/usage_text.h7
5 files changed, 30 insertions, 3 deletions
diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc
index b25c4462..c1c93708 100644
--- a/src/BtCheckIntegrityEntry.cc
+++ b/src/BtCheckIntegrityEntry.cc
@@ -77,9 +77,12 @@ void BtCheckIntegrityEntry::onDownloadFinished
{
auto group = getRequestGroup();
const auto& option = group->getOption();
- util::executeHookByOptName(group, option.get(), PREF_ON_BT_DOWNLOAD_COMPLETE);
- SingletonHolder<Notifier>::instance()->notifyDownloadEvent
- (EVENT_ON_BT_DOWNLOAD_COMPLETE, group);
+ if(option->getAsBool(PREF_BT_ENABLE_HOOK_AFTER_HASH_CHECK)) {
+ util::executeHookByOptName(group, option.get(),
+ PREF_ON_BT_DOWNLOAD_COMPLETE);
+ SingletonHolder<Notifier>::instance()->notifyDownloadEvent
+ (EVENT_ON_BT_DOWNLOAD_COMPLETE, group);
+ }
// TODO Currently,when all the checksums
// 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
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index 3967d3c7..02d78fc0 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -1751,6 +1751,18 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
}
{
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
(PREF_BT_ENABLE_LPD,
TEXT_BT_ENABLE_LPD,
A2_V_FALSE,
diff --git a/src/prefs.cc b/src/prefs.cc
index 7da29859..815b8b9d 100644
--- a/src/prefs.cc
+++ b/src/prefs.cc
@@ -556,6 +556,9 @@ PrefPtr PREF_BT_REMOVE_UNSELECTED_FILE =
makePref("bt-remove-unselected-file");
PrefPtr PREF_BT_DETACH_SEED_ONLY = makePref("bt-detach-seed-only");
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
diff --git a/src/prefs.h b/src/prefs.h
index 615f8449..f8115f52 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -494,6 +494,8 @@ extern PrefPtr PREF_BT_REMOVE_UNSELECTED_FILE;
extern PrefPtr PREF_BT_DETACH_SEED_ONLY;
// values: true | false
extern PrefPtr PREF_BT_FORCE_ENCRYPTION;
+// values: true | false
+extern PrefPtr PREF_BT_ENABLE_HOOK_AFTER_HASH_CHECK;
/**
* Metalink related preferences
diff --git a/src/usage_text.h b/src/usage_text.h
index 9a4b93c3..09c4ae33 100644
--- a/src/usage_text.h
+++ b/src/usage_text.h
@@ -1046,3 +1046,10 @@
" Specifing 0 will disable this option. This value\n" \
" will be set to socket file descriptor using\n" \
" 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.")