From 9deb4210b2c94446126e66c7994d745643cd39c9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 20 May 2017 13:00:11 +0900 Subject: [PATCH] Add --bt-load-saved-metadata option Before getting torrent metadata from DHT when downloading with magnet link, first try to read file saved by --bt-save-metadata option. If it is successful, then skip downloading metadata from DHT. By default, this feature is turned off. --- src/OptionHandlerFactory.cc | 10 +++++++++ src/download_helper.cc | 41 ++++++++++++++++++++++++++++++++----- src/prefs.cc | 2 ++ src/prefs.h | 2 ++ src/usage_text.h | 8 ++++++++ 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index b1721c80..6f352cd4 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -1527,6 +1527,16 @@ std::vector OptionHandlerFactory::createOptionHandlers() op->setChangeOptionForReserved(true); handlers.push_back(op); } + { + OptionHandler* op(new BooleanOptionHandler( + PREF_BT_LOAD_SAVED_METADATA, TEXT_BT_LOAD_SAVED_METADATA, A2_V_FALSE, + OptionHandler::OPT_ARG)); + op->addTag(TAG_BITTORRENT); + op->setInitialOption(true); + op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); + handlers.push_back(op); + } { OptionHandler* op(new DefaultOptionHandler( PREF_BT_LPD_INTERFACE, TEXT_BT_LPD_INTERFACE, NO_DEFAULT_VALUE, diff --git a/src/download_helper.cc b/src/download_helper.cc index 9a19fe2f..7caf8c43 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -237,23 +237,54 @@ std::shared_ptr createBtMagnetRequestGroup(const std::string& magnetLink, const std::shared_ptr