Prechádzať zdrojové kódy

2008-10-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Added --auto-save-interval=SEC option. A control file(*.aria2) 
is saved
	every SEC seconds.
	* src/DownloadEngineFactory.cc
	* src/OptionHandlerFactory.cc
	* src/option_processing.cc
	* src/usage_text.h
Tatsuhiro Tsujikawa 17 rokov pred
rodič
commit
3779b4cf3e

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2008-10-13  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Added --auto-save-interval=SEC option. A control file(*.aria2) is saved
+	every SEC seconds.
+	* src/DownloadEngineFactory.cc
+	* src/OptionHandlerFactory.cc
+	* src/option_processing.cc
+	* src/usage_text.h
+
 2008-10-13  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Fixed compile warning on linux-amd64

+ 5 - 1
src/DownloadEngineFactory.cc

@@ -91,7 +91,11 @@ DownloadEngineFactory::newDownloadEngine(Option* op,
 #endif // ENABLE_MESSAGE_DIGEST
   e->addRoutineCommand(new FillRequestGroupCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 1));
   e->addRoutineCommand(new FileAllocationDispatcherCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get()));
-  e->addRoutineCommand(new AutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
+  if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
+    e->addRoutineCommand
+      (new AutoSaveCommand(CUIDCounterSingletonHolder::instance()->newID(),
+			   e.get(), op->getAsInt(PREF_AUTO_SAVE_INTERVAL)));
+  }
   e->addRoutineCommand(new HaveEraseCommand(CUIDCounterSingletonHolder::instance()->newID(), e.get(), 10));
   {
     time_t stopSec = op->getAsInt(PREF_STOP);

+ 3 - 3
src/OptionHandlerFactory.cc

@@ -83,10 +83,10 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
   {
     SharedHandle<OptionHandler> op(new NumberOptionHandler
 				   (PREF_AUTO_SAVE_INTERVAL,
-				    NO_DESCRIPTION,
+				    TEXT_AUTO_SAVE_INTERVAL,
 				    "60",
-				    1, 600,
-				    true));
+				    0, 600));
+    op->addTag(TAG_ADVANCED);
     handlers.push_back(op);
   }
   {

+ 4 - 0
src/option_processing.cc

@@ -160,6 +160,7 @@ Option* option_processing(int argc, char* const argv[])
       { PREF_REMOTE_TIME.c_str(), optional_argument, 0, 'R' },
       { PREF_CONNECT_TIMEOUT.c_str(), required_argument, &lopt, 224 },
       { PREF_MAX_FILE_NOT_FOUND.c_str(), required_argument, &lopt, 225 },
+      { PREF_AUTO_SAVE_INTERVAL.c_str(), required_argument, &lopt, 226 },
 #if defined ENABLE_BITTORRENT || defined ENABLE_METALINK
       { PREF_SHOW_FILES.c_str(), no_argument, NULL, 'S' },
       { PREF_SELECT_FILE.c_str(), required_argument, &lopt, 21 },
@@ -405,6 +406,9 @@ Option* option_processing(int argc, char* const argv[])
       case 225:
 	cmdstream << PREF_MAX_FILE_NOT_FOUND << "=" << optarg << "\n";
 	break;
+      case 226:
+	cmdstream << PREF_AUTO_SAVE_INTERVAL << "=" << optarg << "\n";
+	break;
       }
       break;
     }

+ 5 - 0
src/usage_text.h

@@ -373,3 +373,8 @@ _(" --server-stat-if=FILE        Specify the filename to load performance profil
 _(" --server-stat-timeout=SEC    Specifies timeout in seconds to invalidate\n"\
   "                              performance profile of the servers since the last\n"\
   "                              contact to them.")
+#define TEXT_AUTO_SAVE_INTERVAL \
+_(" --auto-save-interval=SEC     Save a control file(*.aria2) every SEC seconds.\n"\
+  "                              If 0 is given, a control file is not saved during\n"\
+  "                              download. aria2 saves a control file when it stops\n"\
+  "                              regardless of the value.")