From 6bc215fcec22d8bdf760c78cc25cb8798266c8a5 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 29 Nov 2010 21:06:39 +0900 Subject: [PATCH] Add groupToAdd to requestGroups_ even if exception is thrown in createInitialCommand(). This makes groupToAdd be processed by removeStoppedGroup() and --on-download-error hook is properly triggered. Now --on-download-start is also triggered for groupToAdd even if exception is thrown in createInitialCommand(). --- src/RequestGroupMan.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index ff4257c1..a99e9a2b 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -516,8 +516,6 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) ++count; e->addCommand(commands); commands.clear(); - util::executeHookByOptName - (groupToAdd, e->getOption(), PREF_ON_DOWNLOAD_START); } catch(RecoverableException& ex) { A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex); A2_LOG_DEBUG("Deleting temporal commands."); @@ -525,9 +523,13 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) commands.clear(); A2_LOG_DEBUG("Commands deleted"); groupToAdd->setLastErrorCode(ex.getErrorCode()); - groupToAdd->releaseRuntimeResource(e); - addDownloadResult(groupToAdd->createDownloadResult()); + // We add groupToAdd to e in order to it is processed in + // removeStoppedGroup(). + requestGroups_.push_back(groupToAdd); + requestQueueCheck(); } + util::executeHookByOptName + (groupToAdd, e->getOption(), PREF_ON_DOWNLOAD_START); } if(!temp.empty()) { reservedGroups_.insert(reservedGroups_.begin(), temp.begin(), temp.end());