diff --git a/ChangeLog b/ChangeLog index e79c7f25..783b49ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-10-15 Tatsuhiro Tsujikawa + + Fixed the bug that prevents remote Metalink/Torrent file from begin + processed. + * src/RequestGroupMan.cc (removeStoppedGroup) + + Added debug message. + * src/BtPostDownloadHandler.cc + * src/MetalinkPostDownloadHandler.cc + * src/PostDownloadHandler.{h, cc} + * src/RequestGroup.cc + 2007-10-15 Tatsuhiro Tsujikawa * src/Request.cc (parseUrl): Removed unnecessary slashes around dir. diff --git a/src/BtPostDownloadHandler.cc b/src/BtPostDownloadHandler.cc index b2fc19b9..096a0e4c 100644 --- a/src/BtPostDownloadHandler.cc +++ b/src/BtPostDownloadHandler.cc @@ -37,6 +37,7 @@ #include "prefs.h" #include "RequestGroup.h" #include "Option.h" +#include "Logger.h" BtPostDownloadHandler::BtPostDownloadHandler(const Option* option): PostDownloadHandler(".torrent", option) @@ -46,6 +47,7 @@ BtPostDownloadHandler::~BtPostDownloadHandler() {} RequestGroups BtPostDownloadHandler::getNextRequestGroups(const string& path) { + _logger->debug("Generating RequestGroups for Torrent file %s", path.c_str()); RequestGroupHandle rg = new RequestGroup(_option, Strings()); DefaultBtContextHandle btContext = new DefaultBtContext(); btContext->load(path); diff --git a/src/MetalinkPostDownloadHandler.cc b/src/MetalinkPostDownloadHandler.cc index de6e9695..56f24b63 100644 --- a/src/MetalinkPostDownloadHandler.cc +++ b/src/MetalinkPostDownloadHandler.cc @@ -35,6 +35,7 @@ #include "MetalinkPostDownloadHandler.h" #include "RequestGroup.h" #include "Metalink2RequestGroup.h" +#include "Logger.h" MetalinkPostDownloadHandler::MetalinkPostDownloadHandler(const Option* option): PostDownloadHandler(".metalink", option) @@ -44,5 +45,6 @@ MetalinkPostDownloadHandler::~MetalinkPostDownloadHandler() {} RequestGroups MetalinkPostDownloadHandler::getNextRequestGroups(const string& path) { + _logger->debug("Generating RequestGroups for Metalink file %s", path.c_str()); return Metalink2RequestGroup(_option).generate(path); } diff --git a/src/PostDownloadHandler.cc b/src/PostDownloadHandler.cc index d7eab07e..9afb549f 100644 --- a/src/PostDownloadHandler.cc +++ b/src/PostDownloadHandler.cc @@ -34,9 +34,9 @@ /* copyright --> */ #include "PostDownloadHandler.h" #include "Util.h" +#include "LogFactory.h" -PostDownloadHandler::PostDownloadHandler(const string& extension, const Option* option):_extension(extension), _option(option) -{} +PostDownloadHandler::PostDownloadHandler(const string& extension, const Option* option):_extension(extension), _option(option), _logger(LogFactory::getInstance()) {} PostDownloadHandler::~PostDownloadHandler() {} diff --git a/src/PostDownloadHandler.h b/src/PostDownloadHandler.h index 70a0b5ce..0a630f40 100644 --- a/src/PostDownloadHandler.h +++ b/src/PostDownloadHandler.h @@ -41,6 +41,7 @@ class Option; class RequestGroup; typedef SharedHandle RequestGroupHandle; typedef deque RequestGroups; +class Logger; class PostDownloadHandler { @@ -48,6 +49,7 @@ private: string _extension; protected: const Option* _option; + const Logger* _logger; public: PostDownloadHandler(const string& extension, const Option* option); diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 6d75bad0..bcbf0a62 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -409,12 +409,14 @@ void RequestGroup::releaseRuntimeResource() RequestGroups RequestGroup::postDownloadProcessing() { + _logger->debug("Finding PostDownloadHandler for path %s.", getFilePath().c_str()); for(PostDownloadHandlers::const_iterator itr = _postDownloadHandlers.begin(); itr != _postDownloadHandlers.end(); ++itr) { if((*itr)->canHandle(getFilePath())) { return (*itr)->getNextRequestGroups(getFilePath()); } } + _logger->debug("No PostDownloadHandler found."); return RequestGroups(); } diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 00f8d031..43bb91c6 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -101,13 +101,16 @@ void RequestGroupMan::removeStoppedGroup() if((*itr)->getNumCommand() > 0) { temp.push_back(*itr); } else { - (*itr)->closeFile(); - RequestGroups nextGroups = (*itr)->postDownloadProcessing(); - + (*itr)->closeFile(); if((*itr)->downloadFinished()) { _logger->notice(MSG_FILE_DOWNLOAD_COMPLETED, (*itr)->getFilePath().c_str()); (*itr)->getProgressInfoFile()->removeFile(); + RequestGroups nextGroups = (*itr)->postDownloadProcessing(); + if(nextGroups.size() > 0) { + _logger->debug("Adding %d RequestGroups as a result of PostDownloadHandler.", (int32_t)nextGroups.size()); + copy(nextGroups.rbegin(), nextGroups.rend(), front_inserter(_reservedGroups)); + } } else { try { (*itr)->getProgressInfoFile()->save();