Add CreateRequestCommand with STATUS_INACTIVE instead of SleepCommand

+ DownloadFailureException.

Throwing DownloadFailureException may stop download unexpectedly when
--reuse-uri is false. Using CreateRequestCommand with STATUS_INACTIVE,
they can be executed next iteration with
DownloadEngine::setRefreshInterval(0).
pull/1/head
Tatsuhiro Tsujikawa 2011-05-16 22:01:49 +09:00
parent c9fe4c64f5
commit 653f04ef5c
1 changed files with 8 additions and 7 deletions

View File

@ -211,10 +211,10 @@ bool AbstractCommand::execute() {
// no URIs available, so don't retry. // no URIs available, so don't retry.
if(getSegmentMan()->allSegmentsIgnored()) { if(getSegmentMan()->allSegmentsIgnored()) {
A2_LOG_DEBUG("All segments are ignored."); A2_LOG_DEBUG("All segments are ignored.");
// In this case, the error might be already set in // This will execute other idle Commands and let them
// RequestGroup, so use it here. // finish quickly.
throw DOWNLOAD_FAILURE_EXCEPTION2 e_->setRefreshInterval(0);
("No URI available.", requestGroup_->getLastErrorCode()); return true;
} else { } else {
return prepareForRetry(1); return prepareForRetry(1);
} }
@ -383,9 +383,10 @@ bool AbstractCommand::prepareForRetry(time_t wait) {
e_->setNoWait(true); e_->setNoWait(true);
e_->addCommand(command); e_->addCommand(command);
} else { } else {
SleepCommand* scom = new SleepCommand(getCuid(), e_, requestGroup_, // We don't use wait so that Command can be executed by
command, wait); // DownloadEngine::setRefreshInterval(0).
e_->addCommand(scom); command->setStatus(Command::STATUS_INACTIVE);
e_->addCommand(command);
} }
return true; return true;
} }