summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-15 13:22:02 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-15 13:22:02 +0000
commit0ead885da520532b2ee16d78f18920522cac472b (patch)
treed619c267d247f8a45da73a38298ef021154ca1dd /src
parentc0b467273c9849aa7ec43f9d2c259ad1a098e77e (diff)
2007-10-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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
Diffstat (limited to 'src')
-rw-r--r--src/BtPostDownloadHandler.cc2
-rw-r--r--src/MetalinkPostDownloadHandler.cc2
-rw-r--r--src/PostDownloadHandler.cc4
-rw-r--r--src/PostDownloadHandler.h2
-rw-r--r--src/RequestGroup.cc2
-rw-r--r--src/RequestGroupMan.cc9
6 files changed, 16 insertions, 5 deletions
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<RequestGroup> RequestGroupHandle;
typedef deque<RequestGroupHandle> 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();