/* */ #include "ChecksumCheckIntegrityEntry.h" #include "RequestGroup.h" #include "DownloadContext.h" #include "FileEntry.h" #include "IteratableChecksumValidator.h" #include "DownloadEngine.h" #include "PieceStorage.h" #include "FileAllocationEntry.h" #include "StreamFileAllocationEntry.h" namespace aria2 { ChecksumCheckIntegrityEntry::ChecksumCheckIntegrityEntry(RequestGroup* requestGroup, Command* nextCommand): CheckIntegrityEntry(requestGroup, nextCommand), redownload_(false) {} ChecksumCheckIntegrityEntry::~ChecksumCheckIntegrityEntry() {} bool ChecksumCheckIntegrityEntry::isValidationReady() { const SharedHandle& dctx = getRequestGroup()->getDownloadContext(); return dctx->isChecksumVerificationAvailable(); } void ChecksumCheckIntegrityEntry::initValidator() { SharedHandle validator (new IteratableChecksumValidator(getRequestGroup()->getDownloadContext(), getRequestGroup()->getPieceStorage())); validator->init(); setValidator(validator); } void ChecksumCheckIntegrityEntry::onDownloadFinished (std::vector& commands, DownloadEngine* e) { getRequestGroup()->getDownloadContext()->setChecksumVerified(true); } void ChecksumCheckIntegrityEntry::onDownloadIncomplete (std::vector& commands, DownloadEngine* e) { if(redownload_) { SharedHandle entry (new StreamFileAllocationEntry(getRequestGroup(), popNextCommand())); proceedFileAllocation(commands, entry, e); } } } // namespace aria2