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