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
pull/1/head
Tatsuhiro Tsujikawa 2007-10-15 13:22:02 +00:00
parent c0b467273c
commit 0ead885da5
7 changed files with 28 additions and 5 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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);
}

View File

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

View File

@ -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);

View File

@ -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();
}

View File

@ -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();