mirror of https://github.com/aria2/aria2
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --dry-run option. In this mode, aria2 just checks whether the remote file is available and doesn't download data. This option has effect on HTTP/FTP downloads and BitTorrent downloads are canceled in this mode. * src/FtpNegotiationCommand.cc * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/OptionHandlerFactory.cc * src/RequestGroup.cc * src/RequestGroupMan.cc * src/prefs.cc * src/prefs.h * src/usage_text.hpull/1/head
parent
c63ceff5dd
commit
6187d6e506
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added --dry-run option. In this mode, aria2 just checks whether
|
||||
the remote file is available and doesn't download data. This
|
||||
option has effect on HTTP/FTP downloads and BitTorrent downloads
|
||||
are canceled in this mode.
|
||||
* src/FtpNegotiationCommand.cc
|
||||
* src/HttpResponseCommand.cc
|
||||
* src/HttpResponseCommand.h
|
||||
* src/OptionHandlerFactory.cc
|
||||
* src/RequestGroup.cc
|
||||
* src/RequestGroupMan.cc
|
||||
* src/prefs.cc
|
||||
* src/prefs.h
|
||||
* src/usage_text.h
|
||||
|
||||
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed compiler waring
|
||||
|
|
|
@ -363,6 +363,13 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
|||
} else {
|
||||
_requestGroup->initPieceStorage();
|
||||
|
||||
if(e->option->getAsBool(PREF_DRY_RUN)) {
|
||||
_requestGroup->getPieceStorage()->markAllPiecesDone();
|
||||
poolConnection();
|
||||
sequence = SEQ_HEAD_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
BtProgressInfoFileHandle infoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
||||
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
||||
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
||||
|
|
|
@ -197,6 +197,11 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
|
|||
HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
|
||||
_requestGroup->initPieceStorage();
|
||||
|
||||
if(e->option->getAsBool(PREF_DRY_RUN)) {
|
||||
onDryRunFileFound();
|
||||
return true;
|
||||
}
|
||||
|
||||
BtProgressInfoFileHandle infoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
||||
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
||||
return true;
|
||||
|
@ -270,6 +275,13 @@ static SharedHandle<Decoder> getContentEncodingDecoder
|
|||
bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResponse) {
|
||||
// We assume that RequestGroup::getTotalLength() == 0 here
|
||||
HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
|
||||
|
||||
if(e->option->getAsBool(PREF_DRY_RUN)) {
|
||||
_requestGroup->initPieceStorage();
|
||||
onDryRunFileFound();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(req->getMethod() == Request::METHOD_HEAD) {
|
||||
poolConnection();
|
||||
req->setMethod(Request::METHOD_GET);
|
||||
|
@ -359,4 +371,10 @@ void HttpResponseCommand::poolConnection()
|
|||
}
|
||||
}
|
||||
|
||||
void HttpResponseCommand::onDryRunFileFound()
|
||||
{
|
||||
_requestGroup->getPieceStorage()->markAllPiecesDone();
|
||||
poolConnection();
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -64,6 +64,8 @@ private:
|
|||
void updateLastModifiedTime(const Time& lastModified);
|
||||
|
||||
void poolConnection();
|
||||
|
||||
void onDryRunFileFound();
|
||||
protected:
|
||||
bool executeInternal();
|
||||
|
||||
|
|
|
@ -369,6 +369,16 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
|||
op->addTag(TAG_HTTP);
|
||||
handlers.push_back(op);
|
||||
}
|
||||
{
|
||||
SharedHandle<OptionHandler> op(new BooleanOptionHandler
|
||||
(PREF_DRY_RUN,
|
||||
TEXT_DRY_RUN,
|
||||
V_FALSE,
|
||||
OptionHandler::OPT_ARG));
|
||||
op->addTag(TAG_FTP);
|
||||
op->addTag(TAG_HTTP);
|
||||
handlers.push_back(op);
|
||||
}
|
||||
{
|
||||
SharedHandle<OptionHandler> op(new UnitNumberOptionHandler
|
||||
(PREF_LOWEST_SPEED_LIMIT,
|
||||
|
|
|
@ -144,9 +144,10 @@ RequestGroup::RequestGroup(const Option* option,
|
|||
// and add this list.
|
||||
// ACCEPT_METALINK is used for `transparent metalink'.
|
||||
addAcceptType(ACCEPT_METALINK);
|
||||
|
||||
initializePreDownloadHandler();
|
||||
initializePostDownloadHandler();
|
||||
if(!_option->getAsBool(PREF_DRY_RUN)) {
|
||||
initializePreDownloadHandler();
|
||||
initializePostDownloadHandler();
|
||||
}
|
||||
}
|
||||
|
||||
RequestGroup::~RequestGroup() {}
|
||||
|
@ -204,6 +205,11 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
|
|||
{
|
||||
BtContextHandle btContext = dynamic_pointer_cast<BtContext>(_downloadContext);
|
||||
if(!btContext.isNull()) {
|
||||
if(_option->getAsBool(PREF_DRY_RUN)) {
|
||||
throw DownloadFailureException
|
||||
("Cancel BitTorrent download in dry-run context.");
|
||||
}
|
||||
|
||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
||||
throw DownloadFailureException
|
||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||
|
@ -328,7 +334,8 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
|
|||
#endif // ENABLE_BITTORRENT
|
||||
// TODO I assume here when totallength is set to DownloadContext and it is
|
||||
// not 0, then filepath is also set DownloadContext correctly....
|
||||
if(_downloadContext->getTotalLength() == 0) {
|
||||
if(_option->getAsBool(PREF_DRY_RUN) ||
|
||||
_downloadContext->getTotalLength() == 0) {
|
||||
createNextCommand(commands, e, 1, method);
|
||||
}else {
|
||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
||||
|
|
|
@ -317,7 +317,8 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
|||
configureRequestGroup(groupToAdd);
|
||||
Commands commands;
|
||||
createInitialCommand(groupToAdd, commands, e,
|
||||
_option->getAsBool(PREF_USE_HEAD));
|
||||
_option->getAsBool(PREF_USE_HEAD)||
|
||||
_option->getAsBool(PREF_DRY_RUN));
|
||||
_requestGroups.push_back(groupToAdd);
|
||||
++count;
|
||||
e->addCommand(commands);
|
||||
|
|
|
@ -158,6 +158,8 @@ const std::string PREF_HTTP_SERVER_LISTEN_PORT("http-server-listen-port");
|
|||
const std::string PREF_ENABLE_HTTP_SERVER("enable-http-server");
|
||||
// value: true | false
|
||||
const std::string PREF_RESET_URI("reset-uri");
|
||||
// value: true | false
|
||||
const std::string PREF_DRY_RUN("dry-run");
|
||||
|
||||
/**
|
||||
* FTP related preferences
|
||||
|
|
|
@ -162,6 +162,8 @@ extern const std::string PREF_HTTP_SERVER_LISTEN_PORT;
|
|||
extern const std::string PREF_ENABLE_HTTP_SERVER;
|
||||
// value: true | false
|
||||
extern const std::string PREF_RESET_URI;
|
||||
// value: true | false
|
||||
extern const std::string PREF_DRY_RUN;
|
||||
|
||||
/**
|
||||
* FTP related preferences
|
||||
|
|
|
@ -499,3 +499,9 @@ _(" -O, --index-out=INDEX=PATH Set file path for file with index=INDEX. You ca
|
|||
" PATH is a relative path to the path specified in\n"\
|
||||
" --dir option. You can use this option multiple\n"\
|
||||
" times.")
|
||||
#define TEXT_DRY_RUN \
|
||||
_(" --dry-run[=true|false] If true is given, aria2 just checks whether the\n"\
|
||||
" remote file is available and doesn't download\n"\
|
||||
" data. This option has effect on HTTP/FTP downloads\n"\
|
||||
" and BitTorrent downloads are canceled if true is\n"\
|
||||
" specified.")
|
||||
|
|
Loading…
Reference in New Issue