/* */ #include "FtpDownloadCommand.h" #include "Request.h" #include "Socket.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" namespace aria2 { FtpDownloadCommand::FtpDownloadCommand (int cuid, const RequestHandle& req, const SharedHandle& fileEntry, RequestGroup* requestGroup, const SharedHandle& ftpConnection, DownloadEngine* e, const SocketHandle& dataSocket, const SocketHandle& ctrlSocket) :DownloadCommand(cuid, req, fileEntry, requestGroup, e, dataSocket), _ftpConnection(ftpConnection), ctrlSocket(ctrlSocket) {} FtpDownloadCommand::~FtpDownloadCommand() {} bool FtpDownloadCommand::prepareForNextSegment() { if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION) && static_cast(_fileEntry->gtoloff(_segments.front()->getPositionToWrite())) == _fileEntry->getLength()) { Command* command = new FtpFinishDownloadCommand (cuid, req, _fileEntry, _requestGroup, _ftpConnection, e, ctrlSocket); e->commands.push_back(command); if(_requestGroup->downloadFinished()) { // To run checksum checking, we had to call following function here. DownloadCommand::prepareForNextSegment(); } return true; } else { return DownloadCommand::prepareForNextSegment(); } } } // namespace aria2