/* */ #include "CheckIntegrityCommand.h" #include "CheckIntegrityMan.h" #include "CheckIntegrityEntry.h" #include "DownloadEngine.h" #include "RequestGroup.h" #include "Logger.h" #include "message.h" #include "prefs.h" namespace aria2 { CheckIntegrityCommand::CheckIntegrityCommand(int32_t cuid, RequestGroup* requestGroup, DownloadEngine* e, const CheckIntegrityEntryHandle& entry): RealtimeCommand(cuid, requestGroup, e), _entry(entry) { _e->_checkIntegrityMan->addCheckIntegrityEntry(_entry); } CheckIntegrityCommand::~CheckIntegrityCommand() { _e->_checkIntegrityMan->removeCheckIntegrityEntry(_entry); } bool CheckIntegrityCommand::executeInternal() { if(_requestGroup->isHaltRequested()) { return true; } _entry->validateChunk(); if(_entry->finished()) { if(_requestGroup->downloadFinished()) { logger->notice(MSG_VERIFICATION_SUCCESSFUL, _requestGroup->getFilePath().c_str()); _e->addCommand(_entry->onDownloadFinished(_e)); } else { logger->error(MSG_VERIFICATION_FAILED, _requestGroup->getFilePath().c_str()); _e->addCommand(_entry->onDownloadIncomplete(_e)); } return true; } else { _e->commands.push_back(this); return false; } } bool CheckIntegrityCommand::handleException(Exception* e) { logger->error(MSG_FILE_VALIDATION_FAILURE, e, cuid); logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str()); return true; } } // namespace aria2