mirror of https://github.com/aria2/aria2
2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use Option::getAsBool(...) instead of Option::get(...) and compare it with V_TRUE. * src/DefaultPieceStorage.cc * src/DownloadCommand.cc * src/FtpNegotiationCommand.cc * src/HttpRequest.cc * src/InitiateConnectionCommand.cc * src/RequestGroup.ccpull/1/head
parent
0a95211100
commit
a0f8685de3
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Use Option::getAsBool(...) instead of Option::get(...) and compare
|
||||||
|
it with V_TRUE.
|
||||||
|
* src/DefaultPieceStorage.cc
|
||||||
|
* src/DownloadCommand.cc
|
||||||
|
* src/FtpNegotiationCommand.cc
|
||||||
|
* src/HttpRequest.cc
|
||||||
|
* src/InitiateConnectionCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
|
||||||
2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Made Option::get(...) return const reference of std::string.
|
Made Option::get(...) return const reference of std::string.
|
||||||
|
|
|
@ -438,7 +438,7 @@ void DefaultPieceStorage::initStorage()
|
||||||
this->diskAdaptor = directDiskAdaptor;
|
this->diskAdaptor = directDiskAdaptor;
|
||||||
} else {
|
} else {
|
||||||
// file mode == DownloadContext::MULTI
|
// file mode == DownloadContext::MULTI
|
||||||
if(option->get(PREF_DIRECT_FILE_MAPPING) == V_TRUE) {
|
if(option->getAsBool(PREF_DIRECT_FILE_MAPPING)) {
|
||||||
logger->debug("Instantiating MultiDiskAdaptor");
|
logger->debug("Instantiating MultiDiskAdaptor");
|
||||||
MultiDiskAdaptorHandle multiDiskAdaptor(new MultiDiskAdaptor());
|
MultiDiskAdaptorHandle multiDiskAdaptor(new MultiDiskAdaptor());
|
||||||
multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
|
multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
|
||||||
|
|
|
@ -201,7 +201,7 @@ void DownloadCommand::validatePieceHash(const SegmentHandle& segment)
|
||||||
std::string expectedPieceHash =
|
std::string expectedPieceHash =
|
||||||
_requestGroup->getDownloadContext()->getPieceHash(segment->getIndex());
|
_requestGroup->getDownloadContext()->getPieceHash(segment->getIndex());
|
||||||
if(!_messageDigestContext.isNull() &&
|
if(!_messageDigestContext.isNull() &&
|
||||||
e->option->get(PREF_REALTIME_CHUNK_CHECKSUM) == V_TRUE &&
|
e->option->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM) &&
|
||||||
!expectedPieceHash.empty()) {
|
!expectedPieceHash.empty()) {
|
||||||
_messageDigestContext->digestReset();
|
_messageDigestContext->digestReset();
|
||||||
std::string actualPieceHash =
|
std::string actualPieceHash =
|
||||||
|
|
|
@ -93,7 +93,7 @@ bool FtpNegotiationCommand::executeInternal() {
|
||||||
} else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
|
} else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
|
||||||
return true;
|
return true;
|
||||||
} else if(sequence == SEQ_FILE_PREPARATION) {
|
} else if(sequence == SEQ_FILE_PREPARATION) {
|
||||||
if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
|
if(e->option->getAsBool(PREF_FTP_PASV)) {
|
||||||
sequence = SEQ_SEND_PASV;
|
sequence = SEQ_SEND_PASV;
|
||||||
} else {
|
} else {
|
||||||
sequence = SEQ_SEND_PORT;
|
sequence = SEQ_SEND_PORT;
|
||||||
|
@ -262,7 +262,7 @@ bool FtpNegotiationCommand::recvSize() {
|
||||||
} else {
|
} else {
|
||||||
_requestGroup->validateTotalLength(size);
|
_requestGroup->validateTotalLength(size);
|
||||||
}
|
}
|
||||||
if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
|
if(e->option->getAsBool(PREF_FTP_PASV)) {
|
||||||
sequence = SEQ_SEND_PASV;
|
sequence = SEQ_SEND_PASV;
|
||||||
} else {
|
} else {
|
||||||
sequence = SEQ_SEND_PORT;
|
sequence = SEQ_SEND_PORT;
|
||||||
|
|
|
@ -249,11 +249,11 @@ void HttpRequest::addAcceptType(const std::string& type)
|
||||||
|
|
||||||
void HttpRequest::configure(const Option* option)
|
void HttpRequest::configure(const Option* option)
|
||||||
{
|
{
|
||||||
authEnabled = option->get(PREF_HTTP_AUTH_ENABLED) == V_TRUE;
|
authEnabled = option->getAsBool(PREF_HTTP_AUTH_ENABLED);
|
||||||
proxyEnabled =
|
proxyEnabled =
|
||||||
option->get(PREF_HTTP_PROXY_ENABLED) == V_TRUE &&
|
option->getAsBool(PREF_HTTP_PROXY_ENABLED) &&
|
||||||
option->get(PREF_HTTP_PROXY_METHOD) == V_GET;
|
option->get(PREF_HTTP_PROXY_METHOD) == V_GET;
|
||||||
proxyAuthEnabled = option->get(PREF_HTTP_PROXY_AUTH_ENABLED) == V_TRUE;
|
proxyAuthEnabled = option->getAsBool(PREF_HTTP_PROXY_AUTH_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HttpRequest::getPreviousURI() const
|
std::string HttpRequest::getPreviousURI() const
|
||||||
|
|
|
@ -104,7 +104,7 @@ bool InitiateConnectionCommand::executeInternal() {
|
||||||
|
|
||||||
bool InitiateConnectionCommand::useHTTPProxy() const
|
bool InitiateConnectionCommand::useHTTPProxy() const
|
||||||
{
|
{
|
||||||
return e->option->get(PREF_HTTP_PROXY_ENABLED) == V_TRUE;
|
return e->option->getAsBool(PREF_HTTP_PROXY_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -238,8 +238,8 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
|
||||||
_pieceStorage->getDiskAdaptor()->openFile();
|
_pieceStorage->getDiskAdaptor()->openFile();
|
||||||
} else {
|
} else {
|
||||||
if(_pieceStorage->getDiskAdaptor()->fileExists()) {
|
if(_pieceStorage->getDiskAdaptor()->fileExists()) {
|
||||||
if(_option->get(PREF_CHECK_INTEGRITY) != V_TRUE &&
|
if(!_option->getAsBool(PREF_CHECK_INTEGRITY) &&
|
||||||
_option->get(PREF_ALLOW_OVERWRITE) != V_TRUE) {
|
!_option->getAsBool(PREF_ALLOW_OVERWRITE)) {
|
||||||
// TODO we need this->haltRequested = true?
|
// TODO we need this->haltRequested = true?
|
||||||
throw DownloadFailureException
|
throw DownloadFailureException
|
||||||
(StringFormat(MSG_FILE_ALREADY_EXISTS,
|
(StringFormat(MSG_FILE_ALREADY_EXISTS,
|
||||||
|
@ -302,7 +302,7 @@ void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands,
|
||||||
DownloadEngine* e)
|
DownloadEngine* e)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE &&
|
if(e->option->getAsBool(PREF_CHECK_INTEGRITY) &&
|
||||||
entry->isValidationReady()) {
|
entry->isValidationReady()) {
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
CheckIntegrityCommand* command =
|
CheckIntegrityCommand* command =
|
||||||
|
@ -338,8 +338,8 @@ bool RequestGroup::downloadFinishedByFileLength()
|
||||||
{
|
{
|
||||||
// assuming that a control file doesn't exist.
|
// assuming that a control file doesn't exist.
|
||||||
if(!isPreLocalFileCheckEnabled() ||
|
if(!isPreLocalFileCheckEnabled() ||
|
||||||
(_option->get(PREF_ALLOW_OVERWRITE) == V_TRUE) ||
|
_option->getAsBool(PREF_ALLOW_OVERWRITE) ||
|
||||||
((_option->get(PREF_CHECK_INTEGRITY) == V_TRUE) &&
|
(_option->getAsBool(PREF_CHECK_INTEGRITY) &&
|
||||||
!_downloadContext->getPieceHashes().empty())) {
|
!_downloadContext->getPieceHashes().empty())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
|
||||||
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
||||||
} else {
|
} else {
|
||||||
File outfile(getFilePath());
|
File outfile(getFilePath());
|
||||||
if(outfile.exists() && _option->get(PREF_CONTINUE) == V_TRUE) {
|
if(outfile.exists() && _option->getAsBool(PREF_CONTINUE)) {
|
||||||
if(getTotalLength() < outfile.size()) {
|
if(getTotalLength() < outfile.size()) {
|
||||||
throw DlAbortEx
|
throw DlAbortEx
|
||||||
(StringFormat(EX_FILE_LENGTH_MISMATCH_BETWEEN_LOCAL_AND_REMOTE,
|
(StringFormat(EX_FILE_LENGTH_MISMATCH_BETWEEN_LOCAL_AND_REMOTE,
|
||||||
|
@ -386,7 +386,7 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
|
||||||
_pieceStorage->markPiecesDone(outfile.size());
|
_pieceStorage->markPiecesDone(outfile.size());
|
||||||
} else {
|
} else {
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(outfile.exists() && _option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) {
|
||||||
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
||||||
} else {
|
} else {
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
@ -415,12 +415,12 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF
|
||||||
// assuming that a control file does not exist
|
// assuming that a control file does not exist
|
||||||
void RequestGroup::shouldCancelDownloadForSafety()
|
void RequestGroup::shouldCancelDownloadForSafety()
|
||||||
{
|
{
|
||||||
if(_option->get(PREF_ALLOW_OVERWRITE) == V_TRUE) {
|
if(_option->getAsBool(PREF_ALLOW_OVERWRITE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File outfile(getFilePath());
|
File outfile(getFilePath());
|
||||||
if(outfile.exists()) {
|
if(outfile.exists()) {
|
||||||
if(_option->get(PREF_AUTO_FILE_RENAMING) == V_TRUE) {
|
if(_option->getAsBool(PREF_AUTO_FILE_RENAMING)) {
|
||||||
if(tryAutoFileRenaming()) {
|
if(tryAutoFileRenaming()) {
|
||||||
_logger->notice(MSG_FILE_RENAMED, getFilePath().c_str());
|
_logger->notice(MSG_FILE_RENAMED, getFilePath().c_str());
|
||||||
} else {
|
} else {
|
||||||
|
@ -742,13 +742,13 @@ void RequestGroup::initializePreDownloadHandler()
|
||||||
void RequestGroup::initializePostDownloadHandler()
|
void RequestGroup::initializePostDownloadHandler()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
if(_option->get(PREF_FOLLOW_TORRENT) == V_TRUE ||
|
if(_option->getAsBool(PREF_FOLLOW_TORRENT) ||
|
||||||
_option->get(PREF_FOLLOW_TORRENT) == V_MEM) {
|
_option->get(PREF_FOLLOW_TORRENT) == V_MEM) {
|
||||||
_postDownloadHandlers.push_back(DownloadHandlerFactory::getBtPostDownloadHandler());
|
_postDownloadHandlers.push_back(DownloadHandlerFactory::getBtPostDownloadHandler());
|
||||||
}
|
}
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
if(_option->get(PREF_FOLLOW_METALINK) == V_TRUE ||
|
if(_option->getAsBool(PREF_FOLLOW_METALINK) ||
|
||||||
_option->get(PREF_FOLLOW_METALINK) == V_MEM) {
|
_option->get(PREF_FOLLOW_METALINK) == V_MEM) {
|
||||||
_postDownloadHandlers.push_back(DownloadHandlerFactory::getMetalinkPostDownloadHandler());
|
_postDownloadHandlers.push_back(DownloadHandlerFactory::getMetalinkPostDownloadHandler());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue