mirror of https://github.com/aria2/aria2
Call RequestGroupMan::removeStoppedGroup() in
DownloadEngine::onEndOfRun() to process RequestGroup objects currently in-progress. With this change, --on-download-stop/error/complete hooks are properly called for in-progress downloads when Ctrl-C is pressed.pull/1/head
parent
567b424907
commit
0cdfc3d104
|
@ -208,7 +208,7 @@ void DownloadEngine::calculateStatistics()
|
|||
|
||||
void DownloadEngine::onEndOfRun()
|
||||
{
|
||||
requestGroupMan_->updateServerStat();
|
||||
requestGroupMan_->removeStoppedGroup(this);
|
||||
requestGroupMan_->closeFile();
|
||||
requestGroupMan_->save();
|
||||
}
|
||||
|
|
|
@ -634,25 +634,6 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
}
|
||||
o << formatDownloadResult(status, *itr) << "\n";
|
||||
}
|
||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
||||
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
||||
DownloadResultHandle result = (*itr)->createDownloadResult();
|
||||
std::string status;
|
||||
if(result->result == error_code::FINISHED) {
|
||||
status = MARK_OK;
|
||||
++ok;
|
||||
} else {
|
||||
// Since this RequestGroup is not processed by ProcessStoppedRequestGroup,
|
||||
// its download stop time is not reseted.
|
||||
// Reset download stop time and assign sessionTime here.
|
||||
(*itr)->getDownloadContext()->resetDownloadStopTime();
|
||||
result->sessionTime =
|
||||
(*itr)->getDownloadContext()->calculateSessionTime();
|
||||
status = MARK_INPR;
|
||||
++inpr;
|
||||
}
|
||||
o << formatDownloadResult(status, result) << "\n";
|
||||
}
|
||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
||||
reservedGroups_.begin(), eoi = reservedGroups_.end();
|
||||
itr != eoi; ++itr) {
|
||||
|
|
|
@ -184,18 +184,6 @@ void SessionSerializer::save(std::ostream& out) const
|
|||
}
|
||||
}
|
||||
}
|
||||
if(saveInProgress_) {
|
||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||
rgman_->getRequestGroups();
|
||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
||||
groups.begin(), eoi = groups.end(); itr != eoi; ++itr) {
|
||||
SharedHandle<DownloadResult> result = (*itr)->createDownloadResult();
|
||||
if(result->result == error_code::FINISHED) {
|
||||
continue;
|
||||
}
|
||||
writeDownloadResult(out, metainfoCache, result);
|
||||
}
|
||||
}
|
||||
if(saveWaiting_) {
|
||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||
rgman_->getReservedGroups();
|
||||
|
|
Loading…
Reference in New Issue