/* */ #include "SeedCheckCommand.h" #include "DownloadEngine.h" #include "BtRuntime.h" #include "PieceStorage.h" #include "BtContext.h" #include "Logger.h" #include "SeedCriteria.h" #include "message.h" namespace aria2 { SeedCheckCommand::SeedCheckCommand(int cuid, RequestGroup* requestGroup, DownloadEngine* e, const BtContextHandle& btContext, const SeedCriteriaHandle& seedCriteria) :Command(cuid), BtContextAwareCommand(btContext), RequestGroupAware(requestGroup), e(e), seedCriteria(seedCriteria), checkStarted(false) {} bool SeedCheckCommand::execute() { if(btRuntime->isHalt()) { return true; } if(!seedCriteria.get()) { return false; } if(checkPoint.elapsed(1)) { if(!checkStarted) { if(pieceStorage->downloadFinished()) { checkStarted = true; seedCriteria->reset(); } } if(checkStarted) { if(seedCriteria->evaluate()) { logger->notice(MSG_SEEDING_END); btRuntime->setHalt(true); } } } e->commands.push_back(this); return false; } void SeedCheckCommand::setSeedCriteria(const SharedHandle& seedCriteria) { this->seedCriteria = seedCriteria; } } // namespace aria2