/* */ #include "FtpDownloadCommand.h" #include "Request.h" #include "SocketCore.h" #include "Segment.h" #include "DownloadEngine.h" #include "RequestGroup.h" #include "prefs.h" #include "Option.h" #include "FtpFinishDownloadCommand.h" #include "FtpConnection.h" #include "Logger.h" #include "FileEntry.h" #include "SocketRecvBuffer.h" namespace aria2 { FtpDownloadCommand::FtpDownloadCommand (cuid_t cuid, const std::shared_ptr& req, const std::shared_ptr& fileEntry, RequestGroup* requestGroup, const std::shared_ptr& ftpConnection, DownloadEngine* e, const std::shared_ptr& dataSocket, const std::shared_ptr& ctrlSocket) :DownloadCommand(cuid, req, fileEntry, requestGroup, e, dataSocket, std::make_shared(dataSocket)), ftpConnection_(ftpConnection), ctrlSocket_(ctrlSocket) {} FtpDownloadCommand::~FtpDownloadCommand() {} bool FtpDownloadCommand::prepareForNextSegment() { if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION) && getFileEntry()->gtoloff(getSegments().front()->getPositionToWrite()) == getFileEntry()->getLength()) { getDownloadEngine()->addCommand (make_unique (getCuid(), getRequest(), getFileEntry(), getRequestGroup(), ftpConnection_, getDownloadEngine(), ctrlSocket_)); if(getRequestGroup()->downloadFinished()) { // To run checksum checking, we had to call following function here. DownloadCommand::prepareForNextSegment(); } return true; } else { return DownloadCommand::prepareForNextSegment(); } } int64_t FtpDownloadCommand::getRequestEndOffset() const { return getFileEntry()->getLength(); } } // namespace aria2