/* */ #include "FtpFinishDownloadCommand.h" #include #include "Request.h" #include "DownloadEngine.h" #include "prefs.h" #include "Option.h" #include "FtpConnection.h" #include "message.h" #include "StringFormat.h" #include "DlAbortEx.h" #include "SocketCore.h" #include "RequestGroup.h" #include "Logger.h" #include "DownloadContext.h" #include "RequestGroupMan.h" #include "FileAllocationEntry.h" #include "CheckIntegrityEntry.h" #include "ServerStatMan.h" namespace aria2 { FtpFinishDownloadCommand::FtpFinishDownloadCommand (cuid_t cuid, const SharedHandle& req, const SharedHandle& fileEntry, RequestGroup* requestGroup, const SharedHandle& ftpConnection, DownloadEngine* e, const SharedHandle& socket) :AbstractCommand(cuid, req, fileEntry, requestGroup, e, socket), _ftpConnection(ftpConnection) {} // overrides AbstractCommand::execute(). // AbstractCommand::_segments is empty. bool FtpFinishDownloadCommand::execute() { if(_requestGroup->isHaltRequested()) { return true; } try { unsigned int status = _ftpConnection->receiveResponse(); if(status == 0) { e->addCommand(this); return false; } if(status != 226) { throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, status).str()); } if(getOption()->getAsBool(PREF_FTP_REUSE_CONNECTION)) { std::map options; options["baseWorkingDir"] = _ftpConnection->getBaseWorkingDir(); e->poolSocket(req, _ftpConnection->getUser(), createProxyRequest(), socket, options); } } catch(RecoverableException& e) { getLogger()->info(EX_EXCEPTION_CAUGHT, e); } if(_requestGroup->downloadFinished()) { return true; } else { return prepareForRetry(0); } } // This function never be called. bool FtpFinishDownloadCommand::executeInternal() { return true; } } // namespace aria2