2007-10-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

* src/Metalink2RequestGroup.cc (generate): Throw exception 
instead of
	catching it inside the method.
	When no file entry is found in a metalink without querying user
	preferences, throw the exception with the error message that 
suggests
	metalink file is probably broken. 
	* src/RequestGroup.cc (postDownloadProcessing): Catch exception 
here.
pull/1/head
Tatsuhiro Tsujikawa 2007-10-15 14:55:24 +00:00
parent 0ead885da5
commit e8a3167596
4 changed files with 108 additions and 94 deletions

View File

@ -1,3 +1,12 @@
2007-10-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Metalink2RequestGroup.cc (generate): Throw exception instead of
catching it inside the method.
When no file entry is found in a metalink without querying user
preferences, throw the exception with the error message that suggests
metalink file is probably broken.
* src/RequestGroup.cc (postDownloadProcessing): Catch exception here.
2007-10-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that prevents remote Metalink/Torrent file from begin

2
TODO
View File

@ -52,4 +52,4 @@
* Implement duplicate download checking in Bt
* Implement the feature to treat http/ftp as auxuality download method for BitTorrent
* Fixed the download error when sending "CWD //*" to the ftp server

View File

@ -40,7 +40,6 @@
#include "Xml2MetalinkProcessor.h"
#include "Util.h"
#include "message.h"
#include "RecoverableException.h"
#include "BtDependency.h"
#include "SingleFileDownloadContext.h"
@ -94,13 +93,17 @@ public:
RequestGroups Metalink2RequestGroup::generate(const string& metalinkFile)
{
Xml2MetalinkProcessor proc;
try {
MetalinkerHandle metalinker = proc.parseFile(metalinkFile);
if(metalinker->entries.empty()) {
throw new DlAbortEx("No file entry found. Probably, the metalink file is not configured properly or broken.");
}
MetalinkEntries entries =
metalinker->queryEntry(_option->get(PREF_METALINK_VERSION),
_option->get(PREF_METALINK_LANGUAGE),
_option->get(PREF_METALINK_OS));
if(entries.size() == 0) {
_logger->notice(EX_NO_RESULT_WITH_YOUR_PREFS);
return RequestGroups();
}
bool useIndex;
@ -187,9 +190,4 @@ RequestGroups Metalink2RequestGroup::generate(const string& metalinkFile)
groups.push_back(rg);
}
return groups;
} catch(RecoverableException* ex) {
_logger->error(EX_EXCEPTION_CAUGHT, ex);
delete ex;
return RequestGroups();
}
}

View File

@ -49,6 +49,7 @@
#include "LogFactory.h"
#include "DiskAdaptor.h"
#include "DiskWriterFactory.h"
#include "RecoverableException.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "CheckIntegrityCommand.h"
#endif // ENABLE_MESSAGE_DIGEST
@ -410,12 +411,18 @@ void RequestGroup::releaseRuntimeResource()
RequestGroups RequestGroup::postDownloadProcessing()
{
_logger->debug("Finding PostDownloadHandler for path %s.", getFilePath().c_str());
try {
for(PostDownloadHandlers::const_iterator itr = _postDownloadHandlers.begin();
itr != _postDownloadHandlers.end(); ++itr) {
if((*itr)->canHandle(getFilePath())) {
return (*itr)->getNextRequestGroups(getFilePath());
}
}
} catch(RecoverableException* ex) {
_logger->error(EX_EXCEPTION_CAUGHT, ex);
delete ex;
return RequestGroups();
}
_logger->debug("No PostDownloadHandler found.");
return RequestGroups();
}