From de55569de527a5172f14a5ee9f6ecbcf41382e25 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 28 Jul 2013 18:07:29 +0900 Subject: [PATCH] Always save control file if --force-save is given --- doc/manual-src/en/aria2c.rst | 5 +++-- src/RequestGroupMan.cc | 10 +++++----- src/usage_text.h | 6 ++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/manual-src/en/aria2c.rst b/doc/manual-src/en/aria2c.rst index 20a01204..00853031 100644 --- a/doc/manual-src/en/aria2c.rst +++ b/doc/manual-src/en/aria2c.rst @@ -1144,8 +1144,9 @@ Advanced Options .. option:: --force-save[=true|false] Save download with :option:`--save-session <--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. + even if the download is completed or removed. This option also saves + control file in that situations. This may be useful to save + BitTorrent seeding which is recognized as completed state. Default: ``false`` .. option:: --gid= diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 6cae6b34..e3a461eb 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -334,7 +334,8 @@ public: !group->getDownloadContext()->isChecksumVerificationNeeded()) { group->applyLastModifiedTimeToLocalFiles(); group->reportDownloadFinished(); - if(group->allDownloadFinished()) { + if(group->allDownloadFinished() && + !group->getOption()->getAsBool(PREF_FORCE_SAVE)) { group->removeControlFile(); saveSignature(group); } else { @@ -517,11 +518,10 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) void RequestGroupMan::save() { - for(RequestGroupList::iterator itr = requestGroups_.begin(), - eoi = requestGroups_.end(); itr != eoi; ++itr) { - const std::shared_ptr& rg = *itr; + for(auto& rg : requestGroups_) { if(rg->allDownloadFinished() && - !rg->getDownloadContext()->isChecksumVerificationNeeded()) { + !rg->getDownloadContext()->isChecksumVerificationNeeded() && + !rg->getOption()->getAsBool(PREF_FORCE_SAVE)) { rg->removeControlFile(); } else { try { diff --git a/src/usage_text.h b/src/usage_text.h index 98262200..72afcf92 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -921,8 +921,10 @@ #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.") + " option also saves control file in that\n" \ + " situations. This may be useful to save\n" \ + " BitTorrent seeding which is recognized as\n" \ + " completed state.") #define TEXT_DISK_CACHE \ _(" --disk-cache=SIZE Enable disk cache. If SIZE is 0, the disk cache\n" \ " is disabled. This feature caches the downloaded\n" \