/* */ #include "CheckIntegrityCommand.h" #include "CheckIntegrityEntry.h" #include "DownloadEngine.h" #include "RequestGroup.h" #include "Logger.h" #include "message.h" #include "prefs.h" #include "DownloadContext.h" namespace aria2 { CheckIntegrityCommand::CheckIntegrityCommand (int32_t cuid, RequestGroup* requestGroup, DownloadEngine* e, const CheckIntegrityEntryHandle& entry): RealtimeCommand(cuid, requestGroup, e), _entry(entry) {} CheckIntegrityCommand::~CheckIntegrityCommand() {} bool CheckIntegrityCommand::executeInternal() { if(_requestGroup->isHaltRequested()) { return true; } _entry->validateChunk(); if(_entry->finished()) { _e->_checkIntegrityMan->dropPickedEntry(); // Enable control file saving here. See also // RequestGroup::processCheckIntegrityEntry() to know why this is // needed. _requestGroup->enableSaveControlFile(); if(_requestGroup->downloadFinished()) { logger->notice(MSG_VERIFICATION_SUCCESSFUL, _requestGroup->getDownloadContext()->getBasePath().c_str()); std::deque commands; _entry->onDownloadFinished(commands, _e); _e->addCommand(commands); } else { logger->error(MSG_VERIFICATION_FAILED, _requestGroup->getDownloadContext()->getBasePath().c_str()); std::deque commands; _entry->onDownloadIncomplete(commands,_e); _e->addCommand(commands); } _e->setNoWait(true); return true; } else { _e->commands.push_back(this); return false; } } bool CheckIntegrityCommand::handleException(Exception& e) { _e->_checkIntegrityMan->dropPickedEntry(); logger->error(MSG_FILE_VALIDATION_FAILURE, e, cuid); logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getDownloadContext()->getBasePath().c_str()); return true; } } // namespace aria2