mirror of https://github.com/aria2/aria2
Renamed DownloadErrorCode.h as error_code.h. Renamed
downloaderrorcode::Value as error_code::Value.pull/1/head
parent
13e3cf2573
commit
947967fc63
|
@ -248,7 +248,7 @@ bool AbstractCommand::execute() {
|
||||||
e_->removeCachedIPAddress
|
e_->removeCachedIPAddress
|
||||||
(req_->getConnectedHostname(), req_->getConnectedPort());
|
(req_->getConnectedHostname(), req_->getConnectedPort());
|
||||||
}
|
}
|
||||||
throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT);
|
throw DL_RETRY_EX2(EX_TIME_OUT, error_code::TIME_OUT);
|
||||||
}
|
}
|
||||||
e_->addCommand(this);
|
e_->addCommand(this);
|
||||||
return false;
|
return false;
|
||||||
|
@ -264,7 +264,7 @@ bool AbstractCommand::execute() {
|
||||||
err));
|
err));
|
||||||
fileEntry_->addURIResult(req_->getUri(), err.getCode());
|
fileEntry_->addURIResult(req_->getUri(), err.getCode());
|
||||||
requestGroup_->setLastUriResult(req_->getUri(), err.getCode());
|
requestGroup_->setLastUriResult(req_->getUri(), err.getCode());
|
||||||
if(err.getCode() == downloadresultcode::CANNOT_RESUME) {
|
if(err.getCode() == error_code::CANNOT_RESUME) {
|
||||||
requestGroup_->increaseResumeFailureCount();
|
requestGroup_->increaseResumeFailureCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ bool AbstractCommand::execute() {
|
||||||
err);
|
err);
|
||||||
fileEntry_->addURIResult(req_->getUri(), err.getCode());
|
fileEntry_->addURIResult(req_->getUri(), err.getCode());
|
||||||
requestGroup_->setLastUriResult(req_->getUri(), err.getCode());
|
requestGroup_->setLastUriResult(req_->getUri(), err.getCode());
|
||||||
if(err.getCode() == downloadresultcode::CANNOT_RESUME) {
|
if(err.getCode() == error_code::CANNOT_RESUME) {
|
||||||
requestGroup_->increaseResumeFailureCount();
|
requestGroup_->increaseResumeFailureCount();
|
||||||
}
|
}
|
||||||
onAbort();
|
onAbort();
|
||||||
|
@ -393,7 +393,7 @@ void AbstractCommand::onAbort() {
|
||||||
// process.
|
// process.
|
||||||
getOption()->put(PREF_ALWAYS_RESUME, A2_V_TRUE);
|
getOption()->put(PREF_ALWAYS_RESUME, A2_V_TRUE);
|
||||||
std::deque<URIResult> res;
|
std::deque<URIResult> res;
|
||||||
fileEntry_->extractURIResult(res, downloadresultcode::CANNOT_RESUME);
|
fileEntry_->extractURIResult(res, error_code::CANNOT_RESUME);
|
||||||
if(!res.empty()) {
|
if(!res.empty()) {
|
||||||
getSegmentMan()->cancelAllSegments();
|
getSegmentMan()->cancelAllSegments();
|
||||||
getSegmentMan()->eraseSegmentWrittenLengthMemo();
|
getSegmentMan()->eraseSegmentWrittenLengthMemo();
|
||||||
|
|
|
@ -103,7 +103,7 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry)
|
||||||
std::deque<std::string>& uris = fileEntry->getRemainingUris();
|
std::deque<std::string>& uris = fileEntry->getRemainingUris();
|
||||||
// looking for retries
|
// looking for retries
|
||||||
std::deque<URIResult> timeouts;
|
std::deque<URIResult> timeouts;
|
||||||
fileEntry->extractURIResult(timeouts, downloadresultcode::TIME_OUT);
|
fileEntry->extractURIResult(timeouts, error_code::TIME_OUT);
|
||||||
std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris),
|
std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris),
|
||||||
std::mem_fun_ref(&URIResult::getURI));
|
std::mem_fun_ref(&URIResult::getURI));
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ DlAbortEx::DlAbortEx
|
||||||
RecoverableException(file, line, errnoArg, msg) {}
|
RecoverableException(file, line, errnoArg, msg) {}
|
||||||
|
|
||||||
DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
|
DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
|
||||||
downloadresultcode::RESULT code):
|
error_code::Value code):
|
||||||
RecoverableException(file, line, msg, code) {}
|
RecoverableException(file, line, msg, code) {}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
DlAbortEx(const char* file, int line, int errnoArg, const std::string& msg);
|
DlAbortEx(const char* file, int line, int errnoArg, const std::string& msg);
|
||||||
|
|
||||||
DlAbortEx(const char* file, int line, const std::string& msg,
|
DlAbortEx(const char* file, int line, const std::string& msg,
|
||||||
downloadresultcode::RESULT code);
|
error_code::Value code);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DL_ABORT_EX(arg) DlAbortEx(__FILE__, __LINE__, arg)
|
#define DL_ABORT_EX(arg) DlAbortEx(__FILE__, __LINE__, arg)
|
||||||
|
|
|
@ -51,7 +51,7 @@ DlRetryEx::DlRetryEx(const char* file, int line, const std::string& msg,
|
||||||
DlRetryEx::DlRetryEx(const char* file, int line, const DlRetryEx& e):
|
DlRetryEx::DlRetryEx(const char* file, int line, const DlRetryEx& e):
|
||||||
RecoverableException(file, line, e) {}
|
RecoverableException(file, line, e) {}
|
||||||
DlRetryEx::DlRetryEx(const char* file, int line, const std::string& msg,
|
DlRetryEx::DlRetryEx(const char* file, int line, const std::string& msg,
|
||||||
downloadresultcode::RESULT code):
|
error_code::Value code):
|
||||||
RecoverableException(file, line, msg, code) {}
|
RecoverableException(file, line, msg, code) {}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
DlRetryEx(const char* file, int line, const DlRetryEx& e);
|
DlRetryEx(const char* file, int line, const DlRetryEx& e);
|
||||||
|
|
||||||
DlRetryEx(const char* file, int line, const std::string& msg,
|
DlRetryEx(const char* file, int line, const std::string& msg,
|
||||||
downloadresultcode::RESULT code);
|
error_code::Value code);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DL_RETRY_EX(arg) DlRetryEx(__FILE__, __LINE__, arg)
|
#define DL_RETRY_EX(arg) DlRetryEx(__FILE__, __LINE__, arg)
|
||||||
|
|
|
@ -262,7 +262,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const
|
||||||
nowSpeed,
|
nowSpeed,
|
||||||
lowestDownloadSpeedLimit_,
|
lowestDownloadSpeedLimit_,
|
||||||
getRequest()->getHost().c_str()),
|
getRequest()->getHost().c_str()),
|
||||||
downloadresultcode::TOO_SLOW_DOWNLOAD_SPEED);
|
error_code::TOO_SLOW_DOWNLOAD_SPEED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ DownloadFailureException::DownloadFailureException
|
||||||
DownloadFailureException::DownloadFailureException
|
DownloadFailureException::DownloadFailureException
|
||||||
(const char* file, int line,
|
(const char* file, int line,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
downloadresultcode::RESULT code):
|
error_code::Value code):
|
||||||
RecoverableException(file, line, msg, code) {}
|
RecoverableException(file, line, msg, code) {}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
DownloadFailureException(const char* file, int line,
|
DownloadFailureException(const char* file, int line,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
downloadresultcode::RESULT code);
|
error_code::Value code);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DOWNLOAD_FAILURE_EXCEPTION(arg) \
|
#define DOWNLOAD_FAILURE_EXCEPTION(arg) \
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include "DownloadResultCode.h"
|
#include "error_code.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -65,7 +65,7 @@ struct DownloadResult
|
||||||
// milliseconds
|
// milliseconds
|
||||||
int64_t sessionTime;
|
int64_t sessionTime;
|
||||||
|
|
||||||
downloadresultcode::RESULT result;
|
error_code::Value result;
|
||||||
|
|
||||||
// This field contains GIDs. See comment in
|
// This field contains GIDs. See comment in
|
||||||
// RequestGroup.cc::_followedByGIDs.
|
// RequestGroup.cc::_followedByGIDs.
|
||||||
|
|
|
@ -284,7 +284,7 @@ void FileEntry::removeIdenticalURI(const std::string& uri)
|
||||||
uris_.erase(std::remove(uris_.begin(), uris_.end(), uri), uris_.end());
|
uris_.erase(std::remove(uris_.begin(), uris_.end(), uri), uris_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileEntry::addURIResult(std::string uri, downloadresultcode::RESULT result)
|
void FileEntry::addURIResult(std::string uri, error_code::Value result)
|
||||||
{
|
{
|
||||||
uriResults_.push_back(URIResult(uri, result));
|
uriResults_.push_back(URIResult(uri, result));
|
||||||
}
|
}
|
||||||
|
@ -292,9 +292,9 @@ void FileEntry::addURIResult(std::string uri, downloadresultcode::RESULT result)
|
||||||
namespace {
|
namespace {
|
||||||
class FindURIResultByResult {
|
class FindURIResultByResult {
|
||||||
private:
|
private:
|
||||||
downloadresultcode::RESULT r_;
|
error_code::Value r_;
|
||||||
public:
|
public:
|
||||||
FindURIResultByResult(downloadresultcode::RESULT r):r_(r) {}
|
FindURIResultByResult(error_code::Value r):r_(r) {}
|
||||||
|
|
||||||
bool operator()(const URIResult& uriResult) const
|
bool operator()(const URIResult& uriResult) const
|
||||||
{
|
{
|
||||||
|
@ -304,7 +304,7 @@ public:
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void FileEntry::extractURIResult
|
void FileEntry::extractURIResult
|
||||||
(std::deque<URIResult>& res, downloadresultcode::RESULT r)
|
(std::deque<URIResult>& res, error_code::Value r)
|
||||||
{
|
{
|
||||||
std::deque<URIResult>::iterator i =
|
std::deque<URIResult>::iterator i =
|
||||||
std::stable_partition(uriResults_.begin(), uriResults_.end(),
|
std::stable_partition(uriResults_.begin(), uriResults_.end(),
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "URIResult.h"
|
#include "URIResult.h"
|
||||||
#include "DownloadResultCode.h"
|
#include "error_code.h"
|
||||||
#include "A2STR.h"
|
#include "A2STR.h"
|
||||||
#include "TimerA2.h"
|
#include "TimerA2.h"
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public:
|
||||||
|
|
||||||
void removeIdenticalURI(const std::string& uri);
|
void removeIdenticalURI(const std::string& uri);
|
||||||
|
|
||||||
void addURIResult(std::string uri, downloadresultcode::RESULT result);
|
void addURIResult(std::string uri, error_code::Value result);
|
||||||
|
|
||||||
const std::deque<URIResult>& getURIResults() const
|
const std::deque<URIResult>& getURIResults() const
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ public:
|
||||||
// Extracts URIResult whose _result is r and stores them into res.
|
// Extracts URIResult whose _result is r and stores them into res.
|
||||||
// The extracted URIResults are removed from uriResults_.
|
// The extracted URIResults are removed from uriResults_.
|
||||||
void extractURIResult
|
void extractURIResult
|
||||||
(std::deque<URIResult>& res, downloadresultcode::RESULT r);
|
(std::deque<URIResult>& res, error_code::Value r);
|
||||||
|
|
||||||
void setMaxConnectionPerServer(size_t n)
|
void setMaxConnectionPerServer(size_t n)
|
||||||
{
|
{
|
||||||
|
|
|
@ -293,7 +293,7 @@ bool FtpNegotiationCommand::recvCwd()
|
||||||
getRequestGroup()->increaseAndValidateFileNotFoundCount();
|
getRequestGroup()->increaseAndValidateFileNotFoundCount();
|
||||||
if (status == 550)
|
if (status == 550)
|
||||||
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
|
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
|
||||||
downloadresultcode::RESOURCE_NOT_FOUND);
|
error_code::RESOURCE_NOT_FOUND);
|
||||||
else
|
else
|
||||||
throw DL_ABORT_EX(fmt(EX_BAD_STATUS, status));
|
throw DL_ABORT_EX(fmt(EX_BAD_STATUS, status));
|
||||||
}
|
}
|
||||||
|
@ -771,7 +771,7 @@ bool FtpNegotiationCommand::recvRest(const SharedHandle<Segment>& segment) {
|
||||||
if(status != 350) {
|
if(status != 350) {
|
||||||
if(segment && segment->getPositionToWrite() != 0) {
|
if(segment && segment->getPositionToWrite() != 0) {
|
||||||
throw DL_ABORT_EX2("FTP server doesn't support resuming.",
|
throw DL_ABORT_EX2("FTP server doesn't support resuming.",
|
||||||
downloadresultcode::CANNOT_RESUME);
|
error_code::CANNOT_RESUME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sequence_ = SEQ_SEND_RETR;
|
sequence_ = SEQ_SEND_RETR;
|
||||||
|
@ -797,7 +797,7 @@ bool FtpNegotiationCommand::recvRetr() {
|
||||||
getRequestGroup()->increaseAndValidateFileNotFoundCount();
|
getRequestGroup()->increaseAndValidateFileNotFoundCount();
|
||||||
if (status == 550)
|
if (status == 550)
|
||||||
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
|
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
|
||||||
downloadresultcode::RESOURCE_NOT_FOUND);
|
error_code::RESOURCE_NOT_FOUND);
|
||||||
else
|
else
|
||||||
throw DL_ABORT_EX(fmt(EX_BAD_STATUS, status));
|
throw DL_ABORT_EX(fmt(EX_BAD_STATUS, status));
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ void HttpResponse::validateResponse() const
|
||||||
util::itos(responseRange->getStartByte(), true).c_str(),
|
util::itos(responseRange->getStartByte(), true).c_str(),
|
||||||
util::itos(responseRange->getEndByte(), true).c_str(),
|
util::itos(responseRange->getEndByte(), true).c_str(),
|
||||||
util::uitos(responseRange->getEntityLength(), true).c_str()),
|
util::uitos(responseRange->getEntityLength(), true).c_str()),
|
||||||
downloadresultcode::CANNOT_RESUME);
|
error_code::CANNOT_RESUME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -191,7 +191,7 @@ bool HttpSkipResponseCommand::processResponse()
|
||||||
}
|
}
|
||||||
} else if(statusCode == 404) {
|
} else if(statusCode == 404) {
|
||||||
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
|
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
|
||||||
downloadresultcode::RESOURCE_NOT_FOUND);
|
error_code::RESOURCE_NOT_FOUND);
|
||||||
} else {
|
} else {
|
||||||
throw DL_ABORT_EX(fmt(EX_BAD_STATUS, statusCode));
|
throw DL_ABORT_EX(fmt(EX_BAD_STATUS, statusCode));
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,9 +112,9 @@ void MultiUrlRequestInfo::printMessageForContinue()
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
error_code::Value MultiUrlRequestInfo::execute()
|
||||||
{
|
{
|
||||||
downloadresultcode::RESULT returnValue = downloadresultcode::FINISHED;
|
error_code::Value returnValue = error_code::FINISHED;
|
||||||
try {
|
try {
|
||||||
DownloadEngineHandle e =
|
DownloadEngineHandle e =
|
||||||
DownloadEngineFactory().newDownloadEngine(option_.get(), requestGroups_);
|
DownloadEngineFactory().newDownloadEngine(option_.get(), requestGroups_);
|
||||||
|
@ -200,9 +200,9 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
||||||
e->getRequestGroupMan()->getDownloadStat();
|
e->getRequestGroupMan()->getDownloadStat();
|
||||||
if(!s.allCompleted()) {
|
if(!s.allCompleted()) {
|
||||||
printMessageForContinue();
|
printMessageForContinue();
|
||||||
if(s.getLastErrorResult() == downloadresultcode::FINISHED &&
|
if(s.getLastErrorResult() == error_code::FINISHED &&
|
||||||
s.getInProgress() > 0) {
|
s.getInProgress() > 0) {
|
||||||
returnValue = downloadresultcode::IN_PROGRESS;
|
returnValue = error_code::IN_PROGRESS;
|
||||||
} else {
|
} else {
|
||||||
returnValue = s.getLastErrorResult();
|
returnValue = s.getLastErrorResult();
|
||||||
}
|
}
|
||||||
|
@ -220,8 +220,8 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
if(returnValue == downloadresultcode::FINISHED) {
|
if(returnValue == error_code::FINISHED) {
|
||||||
returnValue = downloadresultcode::UNKNOWN_ERROR;
|
returnValue = error_code::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e);
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
* Returns FINISHED if all downloads have completed, otherwise returns the
|
* Returns FINISHED if all downloads have completed, otherwise returns the
|
||||||
* last download result.
|
* last download result.
|
||||||
*/
|
*/
|
||||||
downloadresultcode::RESULT execute();
|
error_code::Value execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<MultiUrlRequestInfo> MultiUrlRequestInfoHandle;
|
typedef SharedHandle<MultiUrlRequestInfo> MultiUrlRequestInfoHandle;
|
||||||
|
|
|
@ -45,28 +45,28 @@ SharedHandle<Exception> RecoverableException::copy() const
|
||||||
RecoverableException::RecoverableException
|
RecoverableException::RecoverableException
|
||||||
(const char* file, int line, const std::string& msg):
|
(const char* file, int line, const std::string& msg):
|
||||||
Exception(file, line, msg),
|
Exception(file, line, msg),
|
||||||
code_(downloadresultcode::UNKNOWN_ERROR) {}
|
code_(error_code::UNKNOWN_ERROR) {}
|
||||||
|
|
||||||
RecoverableException::RecoverableException
|
RecoverableException::RecoverableException
|
||||||
(const char* file, int line, const std::string& msg,
|
(const char* file, int line, const std::string& msg,
|
||||||
const Exception& cause):
|
const Exception& cause):
|
||||||
Exception(file, line, msg, cause),
|
Exception(file, line, msg, cause),
|
||||||
code_(downloadresultcode::UNKNOWN_ERROR) {}
|
code_(error_code::UNKNOWN_ERROR) {}
|
||||||
|
|
||||||
RecoverableException::RecoverableException
|
RecoverableException::RecoverableException
|
||||||
(const char* file, int line,
|
(const char* file, int line,
|
||||||
const RecoverableException& e):
|
const RecoverableException& e):
|
||||||
Exception(file, line, e),
|
Exception(file, line, e),
|
||||||
code_(downloadresultcode::UNKNOWN_ERROR) {}
|
code_(error_code::UNKNOWN_ERROR) {}
|
||||||
|
|
||||||
RecoverableException::RecoverableException
|
RecoverableException::RecoverableException
|
||||||
(const char* file, int line, int errnoArg, const std::string& msg):
|
(const char* file, int line, int errnoArg, const std::string& msg):
|
||||||
Exception(file, line, errnoArg, msg),
|
Exception(file, line, errnoArg, msg),
|
||||||
code_(downloadresultcode::UNKNOWN_ERROR) {}
|
code_(error_code::UNKNOWN_ERROR) {}
|
||||||
|
|
||||||
RecoverableException::RecoverableException
|
RecoverableException::RecoverableException
|
||||||
(const char* file, int line, const std::string& msg,
|
(const char* file, int line, const std::string& msg,
|
||||||
downloadresultcode::RESULT result):
|
error_code::Value result):
|
||||||
Exception(file, line, msg), code_(result) {}
|
Exception(file, line, msg), code_(result) {}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -35,13 +35,13 @@
|
||||||
#ifndef D_RECOVERABLE_EXCEPTION_H
|
#ifndef D_RECOVERABLE_EXCEPTION_H
|
||||||
#define D_RECOVERABLE_EXCEPTION_H
|
#define D_RECOVERABLE_EXCEPTION_H
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "DownloadResultCode.h"
|
#include "error_code.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class RecoverableException:public Exception {
|
class RecoverableException:public Exception {
|
||||||
private:
|
private:
|
||||||
downloadresultcode::RESULT code_;
|
error_code::Value code_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual SharedHandle<Exception> copy() const;
|
virtual SharedHandle<Exception> copy() const;
|
||||||
|
@ -58,9 +58,9 @@ public:
|
||||||
(const char* file, int line, int errnoArg, const std::string& msg);
|
(const char* file, int line, int errnoArg, const std::string& msg);
|
||||||
|
|
||||||
RecoverableException(const char* file, int line, const std::string& msg,
|
RecoverableException(const char* file, int line, const std::string& msg,
|
||||||
downloadresultcode::RESULT result);
|
error_code::Value result);
|
||||||
|
|
||||||
downloadresultcode::RESULT getCode() const { return code_; }
|
error_code::Value getCode() const { return code_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -190,17 +190,17 @@ bool RequestGroup::allDownloadFinished() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadresultcode::RESULT RequestGroup::downloadResult() const
|
error_code::Value RequestGroup::downloadResult() const
|
||||||
{
|
{
|
||||||
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded())
|
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded())
|
||||||
return downloadresultcode::FINISHED;
|
return error_code::FINISHED;
|
||||||
else {
|
else {
|
||||||
if(!lastUriResult_) {
|
if(!lastUriResult_) {
|
||||||
if(haltReason_ == RequestGroup::USER_REQUEST ||
|
if(haltReason_ == RequestGroup::USER_REQUEST ||
|
||||||
haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
||||||
return downloadresultcode::IN_PROGRESS;
|
return error_code::IN_PROGRESS;
|
||||||
} else {
|
} else {
|
||||||
return downloadresultcode::UNKNOWN_ERROR;
|
return error_code::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return lastUriResult_->getResult();
|
return lastUriResult_->getResult();
|
||||||
|
@ -1252,7 +1252,7 @@ void RequestGroup::increaseAndValidateFileNotFoundCount()
|
||||||
segmentMan_->calculateSessionDownloadLength() == 0)) {
|
segmentMan_->calculateSessionDownloadLength() == 0)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt("Reached max-file-not-found count=%u", maxCount),
|
(fmt("Reached max-file-not-found count=%u", maxCount),
|
||||||
downloadresultcode::MAX_FILE_NOT_FOUND);
|
error_code::MAX_FILE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,7 +1279,7 @@ bool RequestGroup::doesUploadSpeedExceed()
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestGroup::setLastUriResult
|
void RequestGroup::setLastUriResult
|
||||||
(const std::string uri, downloadresultcode::RESULT result)
|
(const std::string uri, error_code::Value result)
|
||||||
{
|
{
|
||||||
lastUriResult_.reset(new URIResult(uri, result));
|
lastUriResult_.reset(new URIResult(uri, result));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "TransferStat.h"
|
#include "TransferStat.h"
|
||||||
#include "TimeA2.h"
|
#include "TimeA2.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "DownloadResultCode.h"
|
#include "error_code.h"
|
||||||
#include "MetadataInfo.h"
|
#include "MetadataInfo.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -185,11 +185,11 @@ private:
|
||||||
bool tryAutoFileRenaming();
|
bool tryAutoFileRenaming();
|
||||||
|
|
||||||
// Returns the result code of this RequestGroup. If the download
|
// Returns the result code of this RequestGroup. If the download
|
||||||
// finished, then returns downloadresultcode::FINISHED. If the
|
// finished, then returns error_code::FINISHED. If the
|
||||||
// download didn't finish and error result is available in
|
// download didn't finish and error result is available in
|
||||||
// _uriResults, then last result code is returned. Otherwise
|
// _uriResults, then last result code is returned. Otherwise
|
||||||
// returns downloadresultcode::UNKNOWN_ERROR.
|
// returns error_code::UNKNOWN_ERROR.
|
||||||
downloadresultcode::RESULT downloadResult() const;
|
error_code::Value downloadResult() const;
|
||||||
|
|
||||||
void removeDefunctControlFile
|
void removeDefunctControlFile
|
||||||
(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
||||||
|
@ -481,7 +481,7 @@ public:
|
||||||
maxUploadSpeedLimit_ = speed;
|
maxUploadSpeedLimit_ = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLastUriResult(std::string uri, downloadresultcode::RESULT result);
|
void setLastUriResult(std::string uri, error_code::Value result);
|
||||||
|
|
||||||
void saveControlFile() const;
|
void saveControlFile() const;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ RequestGroupMan::RequestGroupMan
|
||||||
xmlRpc_(option->getAsBool(PREF_ENABLE_XML_RPC)),
|
xmlRpc_(option->getAsBool(PREF_ENABLE_XML_RPC)),
|
||||||
queueCheck_(true),
|
queueCheck_(true),
|
||||||
removedErrorResult_(0),
|
removedErrorResult_(0),
|
||||||
removedLastErrorResult_(downloadresultcode::FINISHED),
|
removedLastErrorResult_(error_code::FINISHED),
|
||||||
maxDownloadResult_(option->getAsInt(PREF_MAX_DOWNLOAD_RESULT))
|
maxDownloadResult_(option->getAsInt(PREF_MAX_DOWNLOAD_RESULT))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -264,11 +264,11 @@ namespace {
|
||||||
void executeStopHook
|
void executeStopHook
|
||||||
(const SharedHandle<DownloadResult>& result, const Option* option)
|
(const SharedHandle<DownloadResult>& result, const Option* option)
|
||||||
{
|
{
|
||||||
if(result->result == downloadresultcode::FINISHED &&
|
if(result->result == error_code::FINISHED &&
|
||||||
!option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
|
!option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
|
||||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE),
|
util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE),
|
||||||
util::itos(result->gid));
|
util::itos(result->gid));
|
||||||
} else if(result->result != downloadresultcode::IN_PROGRESS &&
|
} else if(result->result != error_code::IN_PROGRESS &&
|
||||||
!option->blank(PREF_ON_DOWNLOAD_ERROR)) {
|
!option->blank(PREF_ON_DOWNLOAD_ERROR)) {
|
||||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR),
|
util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR),
|
||||||
util::itos(result->gid));
|
util::itos(result->gid));
|
||||||
|
@ -567,11 +567,11 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
||||||
size_t finished = 0;
|
size_t finished = 0;
|
||||||
size_t error = removedErrorResult_;
|
size_t error = removedErrorResult_;
|
||||||
size_t inprogress = 0;
|
size_t inprogress = 0;
|
||||||
downloadresultcode::RESULT lastError = removedLastErrorResult_;
|
error_code::Value lastError = removedLastErrorResult_;
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||||
downloadResults_.begin(), eoi = downloadResults_.end();
|
downloadResults_.begin(), eoi = downloadResults_.end();
|
||||||
itr != eoi; ++itr) {
|
itr != eoi; ++itr) {
|
||||||
if((*itr)->result == downloadresultcode::FINISHED) {
|
if((*itr)->result == error_code::FINISHED) {
|
||||||
++finished;
|
++finished;
|
||||||
} else {
|
} else {
|
||||||
++error;
|
++error;
|
||||||
|
@ -581,7 +581,7 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
||||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
||||||
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
||||||
DownloadResultHandle result = (*itr)->createDownloadResult();
|
DownloadResultHandle result = (*itr)->createDownloadResult();
|
||||||
if(result->result == downloadresultcode::FINISHED) {
|
if(result->result == error_code::FINISHED) {
|
||||||
++finished;
|
++finished;
|
||||||
} else {
|
} else {
|
||||||
++inprogress;
|
++inprogress;
|
||||||
|
@ -618,10 +618,10 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
downloadResults_.begin(), eoi = downloadResults_.end();
|
downloadResults_.begin(), eoi = downloadResults_.end();
|
||||||
itr != eoi; ++itr) {
|
itr != eoi; ++itr) {
|
||||||
std::string status;
|
std::string status;
|
||||||
if((*itr)->result == downloadresultcode::FINISHED) {
|
if((*itr)->result == error_code::FINISHED) {
|
||||||
status = MARK_OK;
|
status = MARK_OK;
|
||||||
++ok;
|
++ok;
|
||||||
} else if((*itr)->result == downloadresultcode::IN_PROGRESS) {
|
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||||
status = MARK_INPR;
|
status = MARK_INPR;
|
||||||
++inpr;
|
++inpr;
|
||||||
} else {
|
} else {
|
||||||
|
@ -634,7 +634,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
||||||
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
||||||
DownloadResultHandle result = (*itr)->createDownloadResult();
|
DownloadResultHandle result = (*itr)->createDownloadResult();
|
||||||
std::string status;
|
std::string status;
|
||||||
if(result->result == downloadresultcode::FINISHED) {
|
if(result->result == error_code::FINISHED) {
|
||||||
status = MARK_OK;
|
status = MARK_OK;
|
||||||
++ok;
|
++ok;
|
||||||
} else {
|
} else {
|
||||||
|
@ -783,14 +783,14 @@ void RequestGroupMan::addDownloadResult(const SharedHandle<DownloadResult>& dr)
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::iterator i =
|
for(std::deque<SharedHandle<DownloadResult> >::iterator i =
|
||||||
downloadResults_.begin(), eoi = downloadResults_.end(); i != eoi;
|
downloadResults_.begin(), eoi = downloadResults_.end(); i != eoi;
|
||||||
++i) {
|
++i) {
|
||||||
if((*i)->result != downloadresultcode::FINISHED) {
|
if((*i)->result != error_code::FINISHED) {
|
||||||
removedLastErrorResult_ = (*i)->result;
|
removedLastErrorResult_ = (*i)->result;
|
||||||
++removedErrorResult_;
|
++removedErrorResult_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downloadResults_.clear();
|
downloadResults_.clear();
|
||||||
}
|
}
|
||||||
if(dr->result != downloadresultcode::FINISHED) {
|
if(dr->result != error_code::FINISHED) {
|
||||||
removedLastErrorResult_ = dr->result;
|
removedLastErrorResult_ = dr->result;
|
||||||
++removedErrorResult_;
|
++removedErrorResult_;
|
||||||
}
|
}
|
||||||
|
@ -801,7 +801,7 @@ void RequestGroupMan::addDownloadResult(const SharedHandle<DownloadResult>& dr)
|
||||||
downloadResults_.begin()+curSize-maxDownloadResult_+1;
|
downloadResults_.begin()+curSize-maxDownloadResult_+1;
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::iterator i =
|
for(std::deque<SharedHandle<DownloadResult> >::iterator i =
|
||||||
downloadResults_.begin(); i != last; ++i) {
|
downloadResults_.begin(); i != last; ++i) {
|
||||||
if((*i)->result != downloadresultcode::FINISHED) {
|
if((*i)->result != error_code::FINISHED) {
|
||||||
removedLastErrorResult_ = (*i)->result;
|
removedLastErrorResult_ = (*i)->result;
|
||||||
++removedErrorResult_;
|
++removedErrorResult_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ private:
|
||||||
size_t removedErrorResult_;
|
size_t removedErrorResult_;
|
||||||
|
|
||||||
// The last error of removed DownloadResult
|
// The last error of removed DownloadResult
|
||||||
downloadresultcode::RESULT removedLastErrorResult_;
|
error_code::Value removedLastErrorResult_;
|
||||||
|
|
||||||
size_t maxDownloadResult_;
|
size_t maxDownloadResult_;
|
||||||
|
|
||||||
|
@ -172,21 +172,21 @@ public:
|
||||||
size_t error_;
|
size_t error_;
|
||||||
size_t inProgress_;
|
size_t inProgress_;
|
||||||
size_t waiting_;
|
size_t waiting_;
|
||||||
downloadresultcode::RESULT lastErrorResult_;
|
error_code::Value lastErrorResult_;
|
||||||
public:
|
public:
|
||||||
DownloadStat(size_t completed,
|
DownloadStat(size_t completed,
|
||||||
size_t error,
|
size_t error,
|
||||||
size_t inProgress,
|
size_t inProgress,
|
||||||
size_t waiting,
|
size_t waiting,
|
||||||
downloadresultcode::RESULT lastErrorResult =
|
error_code::Value lastErrorResult =
|
||||||
downloadresultcode::FINISHED):
|
error_code::FINISHED):
|
||||||
completed_(completed),
|
completed_(completed),
|
||||||
error_(error),
|
error_(error),
|
||||||
inProgress_(inProgress),
|
inProgress_(inProgress),
|
||||||
waiting_(waiting),
|
waiting_(waiting),
|
||||||
lastErrorResult_(lastErrorResult) {}
|
lastErrorResult_(lastErrorResult) {}
|
||||||
|
|
||||||
downloadresultcode::RESULT getLastErrorResult() const
|
error_code::Value getLastErrorResult() const
|
||||||
{
|
{
|
||||||
return lastErrorResult_;
|
return lastErrorResult_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,9 +171,9 @@ void SessionSerializer::save(std::ostream& out) const
|
||||||
rgman_->getDownloadResults();
|
rgman_->getDownloadResults();
|
||||||
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
for(std::deque<SharedHandle<DownloadResult> >::const_iterator itr =
|
||||||
results.begin(), eoi = results.end(); itr != eoi; ++itr) {
|
results.begin(), eoi = results.end(); itr != eoi; ++itr) {
|
||||||
if((*itr)->result == downloadresultcode::FINISHED) {
|
if((*itr)->result == error_code::FINISHED) {
|
||||||
continue;
|
continue;
|
||||||
} else if((*itr)->result == downloadresultcode::IN_PROGRESS) {
|
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||||
if(saveInProgress_) {
|
if(saveInProgress_) {
|
||||||
writeDownloadResult(out, metainfoCache, *itr);
|
writeDownloadResult(out, metainfoCache, *itr);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ void SessionSerializer::save(std::ostream& out) const
|
||||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
||||||
groups.begin(), eoi = groups.end(); itr != eoi; ++itr) {
|
groups.begin(), eoi = groups.end(); itr != eoi; ++itr) {
|
||||||
SharedHandle<DownloadResult> result = (*itr)->createDownloadResult();
|
SharedHandle<DownloadResult> result = (*itr)->createDownloadResult();
|
||||||
if(result->result == downloadresultcode::FINISHED) {
|
if(result->result == error_code::FINISHED) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
writeDownloadResult(out, metainfoCache, result);
|
writeDownloadResult(out, metainfoCache, result);
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
URIResult::URIResult(const std::string& uri, downloadresultcode::RESULT result)
|
URIResult::URIResult(const std::string& uri, error_code::Value result)
|
||||||
: uri_(uri), result_(result)
|
: uri_(uri), result_(result)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "DownloadResultCode.h"
|
#include "error_code.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ class URIResult {
|
||||||
private:
|
private:
|
||||||
std::string uri_;
|
std::string uri_;
|
||||||
|
|
||||||
downloadresultcode::RESULT result_;
|
error_code::Value result_;
|
||||||
public:
|
public:
|
||||||
URIResult(const std::string& uri, downloadresultcode::RESULT result);
|
URIResult(const std::string& uri, error_code::Value result);
|
||||||
|
|
||||||
~URIResult();
|
~URIResult();
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
return uri_;
|
return uri_;
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadresultcode::RESULT getResult() const
|
error_code::Value getResult() const
|
||||||
{
|
{
|
||||||
return result_;
|
return result_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -739,9 +739,9 @@ void gatherStoppedDownload
|
||||||
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
||||||
}
|
}
|
||||||
if(requested_key(keys, KEY_STATUS)) {
|
if(requested_key(keys, KEY_STATUS)) {
|
||||||
if(ds->result == downloadresultcode::IN_PROGRESS) {
|
if(ds->result == error_code::IN_PROGRESS) {
|
||||||
entryDict->put(KEY_STATUS, VLB_REMOVED);
|
entryDict->put(KEY_STATUS, VLB_REMOVED);
|
||||||
} else if(ds->result == downloadresultcode::FINISHED) {
|
} else if(ds->result == error_code::FINISHED) {
|
||||||
entryDict->put(KEY_STATUS, VLB_COMPLETE);
|
entryDict->put(KEY_STATUS, VLB_COMPLETE);
|
||||||
} else {
|
} else {
|
||||||
entryDict->put(KEY_STATUS, VLB_ERROR);
|
entryDict->put(KEY_STATUS, VLB_ERROR);
|
||||||
|
|
|
@ -32,16 +32,17 @@
|
||||||
* files in the program, then also delete it here.
|
* files in the program, then also delete it here.
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#ifndef D_DOWNLOAD_RESULT_CODE_H
|
#ifndef D_ERROR_CODE_H
|
||||||
#define D_DOWNLOAD_RESULT_CODE_H
|
#define D_ERROR_CODE_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace downloadresultcode {
|
namespace error_code {
|
||||||
|
|
||||||
enum RESULT {
|
enum Value {
|
||||||
|
UNDEFINED = -1,
|
||||||
FINISHED = 0,
|
FINISHED = 0,
|
||||||
UNKNOWN_ERROR = 1,
|
UNKNOWN_ERROR = 1,
|
||||||
TIME_OUT = 2,
|
TIME_OUT = 2,
|
||||||
|
@ -53,8 +54,8 @@ enum RESULT {
|
||||||
CANNOT_RESUME = 8,
|
CANNOT_RESUME = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace downloadresultcode
|
} // namespace error_code
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
#endif // D_DOWNLOAD_RESULT_CODE_H
|
#endif // D_ERROR_CODE_H
|
|
@ -172,7 +172,7 @@ void showFiles
|
||||||
extern void option_processing(Option& option, std::vector<std::string>& uris,
|
extern void option_processing(Option& option, std::vector<std::string>& uris,
|
||||||
int argc, char* const argv[]);
|
int argc, char* const argv[]);
|
||||||
|
|
||||||
downloadresultcode::RESULT main(int argc, char* argv[])
|
error_code::Value main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
SharedHandle<Option> op(new Option());
|
SharedHandle<Option> op(new Option());
|
||||||
|
@ -187,7 +187,7 @@ downloadresultcode::RESULT main(int argc, char* argv[])
|
||||||
if(op->getAsBool(PREF_QUIET)) {
|
if(op->getAsBool(PREF_QUIET)) {
|
||||||
LogFactory::setConsoleOutput(false);
|
LogFactory::setConsoleOutput(false);
|
||||||
}
|
}
|
||||||
downloadresultcode::RESULT exitStatus = downloadresultcode::FINISHED;
|
error_code::Value exitStatus = error_code::FINISHED;
|
||||||
A2_LOG_INFO("<<--- --- --- ---");
|
A2_LOG_INFO("<<--- --- --- ---");
|
||||||
A2_LOG_INFO(" --- --- --- ---");
|
A2_LOG_INFO(" --- --- --- ---");
|
||||||
A2_LOG_INFO(" --- --- --- --->>");
|
A2_LOG_INFO(" --- --- --- --->>");
|
||||||
|
@ -278,13 +278,13 @@ downloadresultcode::RESULT main(int argc, char* argv[])
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
aria2::downloadresultcode::RESULT r;
|
aria2::error_code::Value r;
|
||||||
try {
|
try {
|
||||||
aria2::Platform platform;
|
aria2::Platform platform;
|
||||||
r = aria2::main(argc, argv);
|
r = aria2::main(argc, argv);
|
||||||
} catch(aria2::Exception& ex) {
|
} catch(aria2::Exception& ex) {
|
||||||
std::cerr << EX_EXCEPTION_CAUGHT << "\n" << ex.stackTrace() << std::endl;
|
std::cerr << EX_EXCEPTION_CAUGHT << "\n" << ex.stackTrace() << std::endl;
|
||||||
r = aria2::downloadresultcode::UNKNOWN_ERROR;
|
r = aria2::error_code::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "OptionHandlerException.h"
|
#include "OptionHandlerException.h"
|
||||||
#include "DownloadResultCode.h"
|
#include "error_code.h"
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
#include "bittorrent_helper.h"
|
#include "bittorrent_helper.h"
|
||||||
#ifndef HAVE_DAEMON
|
#ifndef HAVE_DAEMON
|
||||||
|
@ -103,7 +103,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
|
|
||||||
if(op.defined("version")) {
|
if(op.defined("version")) {
|
||||||
showVersion();
|
showVersion();
|
||||||
exit(downloadresultcode::FINISHED);
|
exit(error_code::FINISHED);
|
||||||
}
|
}
|
||||||
if(op.defined("help")) {
|
if(op.defined("help")) {
|
||||||
std::string keyword;
|
std::string keyword;
|
||||||
|
@ -120,7 +120,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showUsage(keyword, oparser);
|
showUsage(keyword, oparser);
|
||||||
exit(downloadresultcode::FINISHED);
|
exit(error_code::FINISHED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,17 +145,17 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
<< oparser.findByName(e.getOptionName())->getDescription()
|
<< oparser.findByName(e.getOptionName())->getDescription()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
} catch(Exception& e) {
|
} catch(Exception& e) {
|
||||||
std::cerr << "Parse error in " << cfname << "\n"
|
std::cerr << "Parse error in " << cfname << "\n"
|
||||||
<< e.stackTrace() << std::endl;
|
<< e.stackTrace() << std::endl;
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
} else if(!ucfname.empty()) {
|
} else if(!ucfname.empty()) {
|
||||||
std::cerr << fmt("Configuration file %s is not found.", cfname.c_str())
|
std::cerr << fmt("Configuration file %s is not found.", cfname.c_str())
|
||||||
<< "\n";
|
<< "\n";
|
||||||
showUsage(TAG_HELP, oparser);
|
showUsage(TAG_HELP, oparser);
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Override configuration with environment variables.
|
// Override configuration with environment variables.
|
||||||
|
@ -175,11 +175,11 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
<< "Usage:" << "\n"
|
<< "Usage:" << "\n"
|
||||||
<< *oparser.findByName(e.getOptionName())
|
<< *oparser.findByName(e.getOptionName())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
} catch(Exception& e) {
|
} catch(Exception& e) {
|
||||||
std::cerr << e.stackTrace() << std::endl;
|
std::cerr << e.stackTrace() << std::endl;
|
||||||
showUsage(TAG_HELP, oparser);
|
showUsage(TAG_HELP, oparser);
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
if(
|
if(
|
||||||
#ifdef ENABLE_XML_RPC
|
#ifdef ENABLE_XML_RPC
|
||||||
|
@ -195,13 +195,13 @@ void option_processing(Option& op, std::vector<std::string>& uris,
|
||||||
if(uris.empty()) {
|
if(uris.empty()) {
|
||||||
std::cerr << MSG_URI_REQUIRED << std::endl;
|
std::cerr << MSG_URI_REQUIRED << std::endl;
|
||||||
showUsage(TAG_HELP, oparser);
|
showUsage(TAG_HELP, oparser);
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(op.getAsBool(PREF_DAEMON)) {
|
if(op.getAsBool(PREF_DAEMON)) {
|
||||||
if(daemon(0, 0) < 0) {
|
if(daemon(0, 0) < 0) {
|
||||||
perror(MSG_DAEMON_FAILED);
|
perror(MSG_DAEMON_FAILED);
|
||||||
exit(downloadresultcode::UNKNOWN_ERROR);
|
exit(error_code::UNKNOWN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,13 +64,13 @@ void FileEntryTest::testRemoveURIWhoseHostnameIs()
|
||||||
void FileEntryTest::testExtractURIResult()
|
void FileEntryTest::testExtractURIResult()
|
||||||
{
|
{
|
||||||
FileEntry fileEntry;
|
FileEntry fileEntry;
|
||||||
fileEntry.addURIResult("http://timeout/file", downloadresultcode::TIME_OUT);
|
fileEntry.addURIResult("http://timeout/file", error_code::TIME_OUT);
|
||||||
fileEntry.addURIResult("http://finished/file", downloadresultcode::FINISHED);
|
fileEntry.addURIResult("http://finished/file", error_code::FINISHED);
|
||||||
fileEntry.addURIResult("http://timeout/file2", downloadresultcode::TIME_OUT);
|
fileEntry.addURIResult("http://timeout/file2", error_code::TIME_OUT);
|
||||||
fileEntry.addURIResult("http://unknownerror/file", downloadresultcode::UNKNOWN_ERROR);
|
fileEntry.addURIResult("http://unknownerror/file", error_code::UNKNOWN_ERROR);
|
||||||
|
|
||||||
std::deque<URIResult> res;
|
std::deque<URIResult> res;
|
||||||
fileEntry.extractURIResult(res, downloadresultcode::TIME_OUT);
|
fileEntry.extractURIResult(res, error_code::TIME_OUT);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, res.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, res.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://timeout/file"), res[0].getURI());
|
CPPUNIT_ASSERT_EQUAL(std::string("http://timeout/file"), res[0].getURI());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("http://timeout/file2"), res[1].getURI());
|
CPPUNIT_ASSERT_EQUAL(std::string("http://timeout/file2"), res[1].getURI());
|
||||||
|
@ -83,7 +83,7 @@ void FileEntryTest::testExtractURIResult()
|
||||||
|
|
||||||
res.clear();
|
res.clear();
|
||||||
|
|
||||||
fileEntry.extractURIResult(res, downloadresultcode::TIME_OUT);
|
fileEntry.extractURIResult(res, error_code::TIME_OUT);
|
||||||
CPPUNIT_ASSERT(res.empty());
|
CPPUNIT_ASSERT(res.empty());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry.getURIResults().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry.getURIResults().size());
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ void FileEntryTest::testReuseUri()
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)0, fileEntry->getRemainingUris().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)0, fileEntry->getRemainingUris().size());
|
||||||
fileEntry->addURIResult("http://localhost/aria2.zip",
|
fileEntry->addURIResult("http://localhost/aria2.zip",
|
||||||
downloadresultcode::UNKNOWN_ERROR);
|
error_code::UNKNOWN_ERROR);
|
||||||
std::vector<std::string> ignore;
|
std::vector<std::string> ignore;
|
||||||
fileEntry->reuseUri(ignore);
|
fileEntry->reuseUri(ignore);
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry->getRemainingUris().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry->getRemainingUris().size());
|
||||||
|
|
|
@ -64,28 +64,28 @@ void RequestGroupTest::testCreateDownloadResult()
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)0, result->sessionTime);
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, result->sessionTime);
|
||||||
// result is UNKNOWN_ERROR if download has not completed and no specific
|
// result is UNKNOWN_ERROR if download has not completed and no specific
|
||||||
// error has been reported
|
// error has been reported
|
||||||
CPPUNIT_ASSERT_EQUAL(downloadresultcode::UNKNOWN_ERROR, result->result);
|
CPPUNIT_ASSERT_EQUAL(error_code::UNKNOWN_ERROR, result->result);
|
||||||
|
|
||||||
// if haltReason is set to RequestGroup::USER_REQUEST, download
|
// if haltReason is set to RequestGroup::USER_REQUEST, download
|
||||||
// result becomes IN_PROGRESS
|
// result becomes IN_PROGRESS
|
||||||
group.setHaltRequested(true, RequestGroup::USER_REQUEST);
|
group.setHaltRequested(true, RequestGroup::USER_REQUEST);
|
||||||
result = group.createDownloadResult();
|
result = group.createDownloadResult();
|
||||||
CPPUNIT_ASSERT_EQUAL(downloadresultcode::IN_PROGRESS, result->result);
|
CPPUNIT_ASSERT_EQUAL(error_code::IN_PROGRESS, result->result);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
group.setLastUriResult
|
group.setLastUriResult
|
||||||
("http://second/file",downloadresultcode::RESOURCE_NOT_FOUND);
|
("http://second/file",error_code::RESOURCE_NOT_FOUND);
|
||||||
|
|
||||||
SharedHandle<DownloadResult> result = group.createDownloadResult();
|
SharedHandle<DownloadResult> result = group.createDownloadResult();
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(downloadresultcode::RESOURCE_NOT_FOUND, result->result);
|
CPPUNIT_ASSERT_EQUAL(error_code::RESOURCE_NOT_FOUND, result->result);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
group.getPieceStorage()->markAllPiecesDone();
|
group.getPieceStorage()->markAllPiecesDone();
|
||||||
|
|
||||||
SharedHandle<DownloadResult> result = group.createDownloadResult();
|
SharedHandle<DownloadResult> result = group.createDownloadResult();
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(downloadresultcode::FINISHED, result->result);
|
CPPUNIT_ASSERT_EQUAL(error_code::FINISHED, result->result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -721,7 +721,7 @@ void XmlRpcMethodTest::testGatherStoppedDownload()
|
||||||
d->inMemoryDownload = false;
|
d->inMemoryDownload = false;
|
||||||
d->sessionDownloadLength = UINT64_MAX;
|
d->sessionDownloadLength = UINT64_MAX;
|
||||||
d->sessionTime = 1000;
|
d->sessionTime = 1000;
|
||||||
d->result = downloadresultcode::FINISHED;
|
d->result = error_code::FINISHED;
|
||||||
d->followedBy = followedBy;
|
d->followedBy = followedBy;
|
||||||
d->belongsTo = 2;
|
d->belongsTo = 2;
|
||||||
SharedHandle<Dict> entry = Dict::g();
|
SharedHandle<Dict> entry = Dict::g();
|
||||||
|
|
Loading…
Reference in New Issue