Browse Source

2009-01-18 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	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
Tatsuhiro Tsujikawa 16 năm trước cách đây
mục cha
commit
809a28fbae
7 tập tin đã thay đổi với 46 bổ sung2 xóa
  1. 16 0
      ChangeLog
  2. 5 1
      src/BtCheckIntegrityEntry.cc
  3. 8 0
      src/OptionHandlerFactory.cc
  4. 4 0
      src/option_processing.cc
  5. 2 0
      src/prefs.cc
  6. 2 0
      src/prefs.h
  7. 9 1
      src/usage_text.h

+ 16 - 0
ChangeLog

@@ -1,3 +1,19 @@
+2009-01-18  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	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  <t-tujikawa@users.sourceforge.net>
 
 	Updated copyright year.

+ 5 - 1
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<Command*>& 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

+ 8 - 0
src/OptionHandlerFactory.cc

@@ -718,6 +718,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
 				    true));
     handlers.push_back(op);
   }
+  {
+    SharedHandle<OptionHandler> op(new BooleanOptionHandler
+				   (PREF_BT_HASH_CHECK_SEED,
+				    TEXT_BT_HASH_CHECK_SEED,
+				    V_TRUE));
+    op->addTag(TAG_BITTORRENT);
+    handlers.push_back(op);
+  }
   {
     SharedHandle<OptionHandler> op(new NumberOptionHandler
 				   (PREF_BT_MAX_OPEN_FILES,

+ 4 - 0
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;

+ 2 - 0
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

+ 2 - 0
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

+ 9 - 1
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"\