Added --force-save option.

--force-save option saves download with --save-session option even if
the download is completed or removed. This may be useful to save
BitTorrent seeding which is recognized as completed state.  The
default value is false.
pull/34/head
Tatsuhiro Tsujikawa 2012-11-17 15:33:44 +09:00
parent 2ee4361848
commit e0dcb942b2
5 changed files with 29 additions and 1 deletions

View File

@ -370,6 +370,19 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
{
OptionHandler* op(new BooleanOptionHandler
(PREF_FORCE_SAVE,
TEXT_FORCE_SAVE,
A2_V_FALSE,
OptionHandler::OPT_ARG));
op->addTag(TAG_ADVANCED);
op->setInitialOption(true);
op->setChangeOption(true);
op->setChangeGlobalOption(true);
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
{
OptionHandler* op(new BooleanOptionHandler
(PREF_FORCE_SEQUENTIAL,

View File

@ -159,7 +159,13 @@ bool SessionSerializer::save(BufferedFile& fp) const
results.begin(), eoi = results.end(); itr != eoi; ++itr) {
if((*itr)->result == error_code::FINISHED ||
(*itr)->result == error_code::REMOVED) {
continue;
if((*itr)->option->getAsBool(PREF_FORCE_SAVE)) {
if(!writeDownloadResult(fp, metainfoCache, *itr)) {
return false;
}
} else {
continue;
}
} else if((*itr)->result == error_code::IN_PROGRESS) {
if(saveInProgress_) {
if(!writeDownloadResult(fp, metainfoCache, *itr)) {

View File

@ -336,6 +336,8 @@ const Pref* PREF_CHECKSUM = makePref("checksum");
const Pref* PREF_STOP_WITH_PROCESS = makePref("stop-with-process");
// value: true | false
const Pref* PREF_ENABLE_MMAP = makePref("enable-mmap");
// value: true | false
const Pref* PREF_FORCE_SAVE = makePref("force-save");
/**
* FTP related preferences

View File

@ -279,6 +279,8 @@ extern const Pref* PREF_CHECKSUM;
extern const Pref* PREF_STOP_WITH_PROCESS;
// value: true | false
extern const Pref* PREF_ENABLE_MMAP;
// value: true | false
extern const Pref* PREF_FORCE_SAVE;
/**
* FTP related preferences

View File

@ -909,3 +909,8 @@
" downloads added by aria2.addTorrent or\n" \
" aria2.addMetalink will not be saved by\n" \
" --save-session option.")
#define TEXT_FORCE_SAVE \
_(" --force-save[=true|false] Save download with --save-session option even\n" \
" if the download is completed or removed. This\n" \
" may be useful to save BitTorrent seeding which\n" \
" is recognized as completed state.")