Sfoglia il codice sorgente

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
Tatsuhiro Tsujikawa 18 anni fa
parent
commit
0ead885da5

+ 12 - 0
ChangeLog

@@ -1,3 +1,15 @@
+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
+
 2007-10-15  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	* src/Request.cc (parseUrl): Removed unnecessary slashes around dir.

+ 2 - 0
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);

+ 2 - 0
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);
 }

+ 2 - 2
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() {}
 

+ 2 - 0
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);
 

+ 2 - 0
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();
 }
 

+ 6 - 3
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();