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 @@ -514,6 +514,16 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); handlers.push_back(op); } + { + SharedHandle 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 op(new BooleanOptionHandler (PREF_QUIET, 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 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 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& listRequestOptions() PREF_BT_TRACKER, PREF_BT_EXCLUDE_TRACKER, PREF_RETRY_WAIT, - PREF_METALINK_BASE_URI + PREF_METALINK_BASE_URI, + PREF_PAUSE }; static std::set requestOptions (vbegin(REQUEST_OPTIONS), vend(REQUEST_OPTIONS)); @@ -228,6 +229,8 @@ SharedHandle 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(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& dctx) } } +void removeOneshotOption(const SharedHandle