mirror of https://github.com/aria2/aria2
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.pull/1/head
parent
c0d1e98133
commit
d5c2ef4ce9
|
@ -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);
|
||||
|
|
|
@ -514,6 +514,16 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
|||
op->addTag(TAG_ADVANCED);
|
||||
handlers.push_back(op);
|
||||
}
|
||||
{
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue