/* */ #include "BtStopDownloadCommand.h" #include "PieceStorage.h" #include "RequestGroup.h" #include "BtRuntime.h" #include "Peer.h" #include "DownloadContext.h" #include "Logger.h" #include "wallclock.h" #include "util.h" namespace aria2 { BtStopDownloadCommand::BtStopDownloadCommand (cuid_t cuid, RequestGroup* requestGroup, DownloadEngine* e, time_t timeout): TimeBasedCommand(cuid, e, 1), _requestGroup(requestGroup), _timeout(timeout) {} void BtStopDownloadCommand::preProcess() { if(_btRuntime->isHalt() || _pieceStorage->downloadFinished()) { enableExit(); } if(_checkPoint.difference(global::wallclock) >= _timeout) { getLogger()->notice("GID#%s Stop downloading torrent due to" " --bt-stop-timeout option.", util::itos(_requestGroup->getGID()).c_str()); _requestGroup->setHaltRequested(true); enableExit(); } } void BtStopDownloadCommand::process() { if(_requestGroup->calculateStat().getDownloadSpeed() > 0) { _checkPoint = global::wallclock; } } } // namespace aria2