diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-06-16 21:37:15 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-06-16 21:37:15 +0900 |
| commit | d5c2ef4ce99db07bedd6313683ac3ff0f2052400 (patch) | |
| tree | 3d64d7173f297dd027ba2d2bca9c5f5c30750f3a | |
| parent | c0d1e981338f9c5f94d2ac600acff5efd340e495 (diff) | |
Added --pause option.
This option pauses download after added. This option is effective only
when --enable-rpc=true is given. When --save-session option is used
and there are paused downloads, they are saved with --pause=true so
that it will become paused state when the session is recovered.
| -rw-r--r-- | src/Metalink2RequestGroup.cc | 2 | ||||
| -rw-r--r-- | src/OptionHandlerFactory.cc | 10 | ||||
| -rw-r--r-- | src/RequestGroupMan.cc | 3 | ||||
| -rw-r--r-- | src/SessionSerializer.cc | 5 | ||||
| -rw-r--r-- | src/download_helper.cc | 14 | ||||
| -rw-r--r-- | src/download_helper.h | 4 | ||||
| -rw-r--r-- | src/main.cc | 1 | ||||
| -rw-r--r-- | src/prefs.cc | 2 | ||||
| -rw-r--r-- | src/prefs.h | 2 | ||||
| -rw-r--r-- | src/usage_text.h | 3 |
10 files changed, 44 insertions, 2 deletions
diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index 4834ce27..ccc3d1b6 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -312,6 +312,8 @@ Metalink2RequestGroup::createRequestGroup rg->setNumConcurrentCommand(option->getAsInt(PREF_METALINK_SERVERS)); } rg->setDownloadContext(dctx); + rg->setPauseRequested(option->getAsBool(PREF_PAUSE)); + removeOneshotOption(rg->getOption()); // remove "metalink" from Accept Type list to avoid loop in // tranparent metalink util::removeMetalinkContentTypes(rg); diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index c5bde6f2..1d8d92b6 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -516,6 +516,16 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new BooleanOptionHandler + (PREF_PAUSE, + TEXT_PAUSE, + A2_V_FALSE, + OptionHandler::OPT_ARG)); + op->addTag(TAG_ADVANCED); + op->addTag(TAG_RPC); + handlers.push_back(op); + } + { + SharedHandle<OptionHandler> op(new BooleanOptionHandler (PREF_QUIET, TEXT_QUIET, A2_V_FALSE, diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 6c3eea14..c46a59a1 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -500,7 +500,8 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) reservedGroups_.pop_front(); std::vector<Command*> commands; try { - if(groupToAdd->isPauseRequested()||!groupToAdd->isDependencyResolved()) { + if((rpc_ && groupToAdd->isPauseRequested()) || + !groupToAdd->isDependencyResolved()) { temp.push_back(groupToAdd); continue; } diff --git a/src/SessionSerializer.cc b/src/SessionSerializer.cc index 4c5acc3c..e904a5ff 100644 --- a/src/SessionSerializer.cc +++ b/src/SessionSerializer.cc @@ -192,6 +192,11 @@ void SessionSerializer::save(std::ostream& out) const groups.begin(), eoi = groups.end(); itr != eoi; ++itr) { SharedHandle<DownloadResult> result = (*itr)->createDownloadResult(); writeDownloadResult(out, metainfoCache, result); + // PREF_PAUSE was removed from option, so save it here looking + // property separately. + if((*itr)->isPauseRequested()) { + out << " " << PREF_PAUSE << "=true" << "\n"; + } } } } diff --git a/src/download_helper.cc b/src/download_helper.cc index 47eca39a..462df731 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -167,7 +167,8 @@ const std::set<std::string>& listRequestOptions() PREF_BT_TRACKER, PREF_BT_EXCLUDE_TRACKER, PREF_RETRY_WAIT, - PREF_METALINK_BASE_URI + PREF_METALINK_BASE_URI, + PREF_PAUSE }; static std::set<std::string> requestOptions (vbegin(REQUEST_OPTIONS), vend(REQUEST_OPTIONS)); @@ -228,6 +229,8 @@ SharedHandle<RequestGroup> createRequestGroup dctx->getFirstFileEntry()->setMaxConnectionPerServer (option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER)); rg->setDownloadContext(dctx); + rg->setPauseRequested(option->getAsBool(PREF_PAUSE)); + removeOneshotOption(rg->getOption()); return rg; } } // namespace @@ -282,9 +285,11 @@ createBtRequestGroup(const std::string& torrentFilePath, ((*i).first, util::applyDir(option->get(PREF_DIR), (*i).second)); } rg->setDownloadContext(dctx); + rg->setPauseRequested(option->getAsBool(PREF_PAUSE)); // Remove "metalink" from Accept Type list to avoid server from // responding Metalink file for web-seeding URIs. util::removeMetalinkContentTypes(rg); + removeOneshotOption(rg->getOption()); return rg; } } // namespace @@ -316,6 +321,8 @@ createBtMagnetRequestGroup(const std::string& magnetLink, (SharedHandle<DiskWriterFactory>(new ByteArrayDiskWriterFactory())); rg->setMetadataInfo(createMetadataInfo(magnetLink)); rg->markInMemoryDownload(); + rg->setPauseRequested(option->getAsBool(PREF_PAUSE)); + removeOneshotOption(rg->getOption()); return rg; } } // namespace @@ -555,4 +562,9 @@ createMetadataInfoFromFirstFileEntry(const SharedHandle<DownloadContext>& dctx) } } +void removeOneshotOption(const SharedHandle<Option>& option) +{ + option->remove(PREF_PAUSE); +} + } // namespace aria2 diff --git a/src/download_helper.h b/src/download_helper.h index 6bd0b7f0..e578b78e 100644 --- a/src/download_helper.h +++ b/src/download_helper.h @@ -112,6 +112,10 @@ void setMetadataInfo SharedHandle<MetadataInfo> createMetadataInfoFromFirstFileEntry(const SharedHandle<DownloadContext>& dctx); +// Removes option value which is only effective at the first +// construction time. +void removeOneshotOption(const SharedHandle<Option>& option); + } // namespace aria2 #endif // D_DOWNLOAD_HELPER_H diff --git a/src/main.cc b/src/main.cc index 57100342..03f464f5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -267,6 +267,7 @@ error_code::Value main(int argc, char* argv[]) op->remove(PREF_INPUT_FILE); op->remove(PREF_INDEX_OUT); op->remove(PREF_SELECT_FILE); + op->remove(PREF_PAUSE); if(!op->getAsBool(PREF_ENABLE_RPC) && requestGroups.empty()) { std::cout << MSG_NO_FILES_TO_DOWNLOAD << std::endl; } else { diff --git a/src/prefs.cc b/src/prefs.cc index f3cff4ce..f8407198 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -226,6 +226,8 @@ const std::string PREF_SHOW_CONSOLE_READOUT("show-console-readout"); const std::string PREF_STREAM_PIECE_SELECTOR("stream-piece-selector"); // value: true | false const std::string PREF_TRUNCATE_CONSOLE_READOUT("truncate-console-readout"); +// value: true | false +const std::string PREF_PAUSE("pause"); /** * FTP related preferences diff --git a/src/prefs.h b/src/prefs.h index 8ea8e0d9..18ab9cb5 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -229,6 +229,8 @@ extern const std::string PREF_SHOW_CONSOLE_READOUT; extern const std::string PREF_STREAM_PIECE_SELECTOR; // value: true | false extern const std::string PREF_TRUNCATE_CONSOLE_READOUT; +// value: true | false +extern const std::string PREF_PAUSE; /** * FTP related preferences diff --git a/src/usage_text.h b/src/usage_text.h index 8d8768d9..6b4e78b2 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -812,3 +812,6 @@ #define TEXT_TRUNCATE_CONSOLE_READOUT \ _(" --truncate-console-readout[=true|false] Truncate console readout to fit in\n"\ " a single line.") +#define TEXT_PAUSE \ + _(" --pause[=true|false] Pause download after added. This option is\n" \ + " effective only when --enable-rpc=true is given.") |
