From 809a28fbae94df53186feb6827af336290850ee4 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 18 Jan 2009 09:04:46 +0000 Subject: [PATCH] 2009-01-18 Tatsuhiro Tsujikawa Added --bt-hash-check-seed option. If true is given to this option, after hash check using --check-integrity option and file is complete, continue to seed file. If you want to check file and download it only when it is damaged or incomplete, set this option to false. This option has effect only on BitTorrent download. The default value is true(This is the same behavior with the previous release). * src/BtCheckIntegrityEntry.cc * src/OptionHandlerFactory.cc * src/option_processing.cc * src/prefs.cc * src/prefs.h * src/usage_text.h --- ChangeLog | 16 ++++++++++++++++ src/BtCheckIntegrityEntry.cc | 6 +++++- src/OptionHandlerFactory.cc | 8 ++++++++ src/option_processing.cc | 4 ++++ src/prefs.cc | 2 ++ src/prefs.h | 2 ++ src/usage_text.h | 10 +++++++++- 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 879d4a36..3ead1324 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2009-01-18 Tatsuhiro Tsujikawa + + Added --bt-hash-check-seed option. If true is given to this + option, after hash check using --check-integrity option and file + is complete, continue to seed file. If you want to check file and + download it only when it is damaged or incomplete, set this option + to false. This option has effect only on BitTorrent download. + The default value is true(This is the same behavior with the + previous release). + * src/BtCheckIntegrityEntry.cc + * src/OptionHandlerFactory.cc + * src/option_processing.cc + * src/prefs.cc + * src/prefs.h + * src/usage_text.h + 2009-01-18 Tatsuhiro Tsujikawa Updated copyright year. diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc index aa14b223..203cf315 100644 --- a/src/BtCheckIntegrityEntry.cc +++ b/src/BtCheckIntegrityEntry.cc @@ -39,6 +39,8 @@ #include "DownloadEngine.h" #include "FileAllocationMan.h" #include "DiskAdaptor.h" +#include "prefs.h" +#include "Option.h" namespace aria2 { @@ -66,7 +68,9 @@ void BtCheckIntegrityEntry::onDownloadFinished(std::deque& commands, // are valid, then aira2 goes to seeding mode. Sometimes it is better // to exit rather than doing seeding. So, it would be good to toggle this // behavior. - onDownloadIncomplete(commands, e); + if(e->option->getAsBool(PREF_BT_HASH_CHECK_SEED)) { + onDownloadIncomplete(commands, e); + } } } // namespace aria2 diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 7d5ba5d9..71d59cfa 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -718,6 +718,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() true)); handlers.push_back(op); } + { + SharedHandle op(new BooleanOptionHandler + (PREF_BT_HASH_CHECK_SEED, + TEXT_BT_HASH_CHECK_SEED, + V_TRUE)); + op->addTag(TAG_BITTORRENT); + handlers.push_back(op); + } { SharedHandle op(new NumberOptionHandler (PREF_BT_MAX_OPEN_FILES, diff --git a/src/option_processing.cc b/src/option_processing.cc index 96ada2b0..a57cab90 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -218,6 +218,7 @@ Option* option_processing(int argc, char* const argv[]) { PREF_BT_SEED_UNVERIFIED.c_str(), optional_argument, &lopt, 34 }, { PREF_DHT_FILE_PATH.c_str(), required_argument, &lopt, 35 }, { PREF_MAX_OVERALL_UPLOAD_LIMIT.c_str(), required_argument, &lopt, 36 }, + { PREF_BT_HASH_CHECK_SEED.c_str(), optional_argument, &lopt, 37 }, #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK { PREF_METALINK_FILE.c_str(), required_argument, NULL, 'M' }, @@ -345,6 +346,9 @@ Option* option_processing(int argc, char* const argv[]) case 36: cmdstream << PREF_MAX_OVERALL_UPLOAD_LIMIT << "=" << optarg << "\n"; break; + case 37: + cmdstream << PREF_BT_HASH_CHECK_SEED << "=" << optarg << "\n"; + break; case 100: cmdstream << PREF_METALINK_VERSION << "=" << optarg << "\n"; break; diff --git a/src/prefs.cc b/src/prefs.cc index fcd68cf9..d9a9cd0d 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -269,6 +269,8 @@ const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT("bt-request-peer-speed-limit" const std::string PREF_BT_MAX_OPEN_FILES("bt-max-open-files"); // values: true | false const std::string PREF_BT_SEED_UNVERIFIED("bt-seed-unverified"); +// values: true | false +const std::string PREF_BT_HASH_CHECK_SEED("bt-hash-check-seed"); /** * Metalink related preferences diff --git a/src/prefs.h b/src/prefs.h index b83c95c3..cddb27c0 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -273,6 +273,8 @@ extern const std::string PREF_BT_REQUEST_PEER_SPEED_LIMIT; extern const std::string PREF_BT_MAX_OPEN_FILES; // values: true | false extern const std::string PREF_BT_SEED_UNVERIFIED; +// values: true | false +extern const std::string PREF_BT_HASH_CHECK_SEED; /** * Metalink related preferences diff --git a/src/usage_text.h b/src/usage_text.h index 91317df7..74e6f899 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -160,7 +160,15 @@ _(" -V, --check-integrity[=true|false] Check file integrity by validating piece\ " hashes. This option has effect only in BitTorrent\n"\ " and Metalink downloads with chunk checksums.\n"\ " Use this option to re-download a damaged portion\n"\ - " of a file.") + " of a file. See also --bt-hash-check-seed option.") +#define TEXT_BT_HASH_CHECK_SEED \ +_(" --bt-hash-check-seed[=true|false] If true is given, after hash check using\n"\ + " --check-integrity option and file is complete,\n"\ + " continue to seed file. If you want to check file\n"\ + " and download it only when it is damaged or\n"\ + " incomplete, set this option to false.\n"\ + " This option has effect only on BitTorrent\n"\ + " download.") #define TEXT_REALTIME_CHUNK_CHECKSUM \ _(" --realtime-chunk-checksum=true|false Validate chunk of data by calculating\n"\ " checksum while downloading a file if chunk\n"\