/* */ #include "CheckIntegrityCommand.h" #include "CheckIntegrityMan.h" #include "CheckIntegrityEntry.h" #include "RequestGroup.h" #include "FileAllocationEntry.h" #include "InitiateConnectionCommandFactory.h" #include "DlAbortEx.h" #include "message.h" #include "DownloadCommand.h" #include "prefs.h" 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()) { _entry->updatePieceStorage(); if(_requestGroup->downloadFinished()) { logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str()); } else { _e->addCommand(_entry->prepareForNextAction(_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; }