/* */ #include "CheckIntegrityEntry.h" #include "IteratableValidator.h" #include "RequestGroup.h" #include "PieceStorage.h" #include "DiskAdaptor.h" #include "prefs.h" #include "FileAllocationEntry.h" #include "DownloadEngine.h" #include "Option.h" namespace aria2 { CheckIntegrityEntry::CheckIntegrityEntry(RequestGroup* requestGroup, std::unique_ptr nextCommand) : RequestGroupEntry{requestGroup, std::move(nextCommand)} { } CheckIntegrityEntry::~CheckIntegrityEntry() {} void CheckIntegrityEntry::validateChunk() { validator_->validateChunk(); } int64_t CheckIntegrityEntry::getTotalLength() { if (!validator_) { return 0; } else { return validator_->getTotalLength(); } } int64_t CheckIntegrityEntry::getCurrentLength() { if (!validator_) { return 0; } else { return validator_->getCurrentOffset(); } } bool CheckIntegrityEntry::finished() { return validator_->finished(); } void CheckIntegrityEntry::cutTrailingGarbage() { getRequestGroup()->getPieceStorage()->getDiskAdaptor()->cutTrailingGarbage(); } void CheckIntegrityEntry::proceedFileAllocation( std::vector>& commands, std::unique_ptr entry, DownloadEngine* e) { if (getRequestGroup()->needsFileAllocation()) { e->getFileAllocationMan()->pushEntry(std::move(entry)); } else { entry->prepareForNextAction(commands, e); } } void CheckIntegrityEntry::setValidator( std::unique_ptr validator) { validator_ = std::move(validator); } } // namespace aria2