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>
|
2009-03-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Fixed compiler waring
|
Fixed compiler waring
|
||||||
|
|
|
@ -363,6 +363,13 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
||||||
} else {
|
} else {
|
||||||
_requestGroup->initPieceStorage();
|
_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));
|
BtProgressInfoFileHandle infoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
||||||
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
||||||
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
||||||
|
|
|
@ -197,6 +197,11 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
|
||||||
HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
|
HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
|
||||||
_requestGroup->initPieceStorage();
|
_requestGroup->initPieceStorage();
|
||||||
|
|
||||||
|
if(e->option->getAsBool(PREF_DRY_RUN)) {
|
||||||
|
onDryRunFileFound();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
BtProgressInfoFileHandle infoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
BtProgressInfoFileHandle infoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
|
||||||
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -270,6 +275,13 @@ static SharedHandle<Decoder> getContentEncodingDecoder
|
||||||
bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResponse) {
|
bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResponse) {
|
||||||
// We assume that RequestGroup::getTotalLength() == 0 here
|
// We assume that RequestGroup::getTotalLength() == 0 here
|
||||||
HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
|
HttpRequestHandle httpRequest = httpResponse->getHttpRequest();
|
||||||
|
|
||||||
|
if(e->option->getAsBool(PREF_DRY_RUN)) {
|
||||||
|
_requestGroup->initPieceStorage();
|
||||||
|
onDryRunFileFound();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(req->getMethod() == Request::METHOD_HEAD) {
|
if(req->getMethod() == Request::METHOD_HEAD) {
|
||||||
poolConnection();
|
poolConnection();
|
||||||
req->setMethod(Request::METHOD_GET);
|
req->setMethod(Request::METHOD_GET);
|
||||||
|
@ -359,4 +371,10 @@ void HttpResponseCommand::poolConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HttpResponseCommand::onDryRunFileFound()
|
||||||
|
{
|
||||||
|
_requestGroup->getPieceStorage()->markAllPiecesDone();
|
||||||
|
poolConnection();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -64,6 +64,8 @@ private:
|
||||||
void updateLastModifiedTime(const Time& lastModified);
|
void updateLastModifiedTime(const Time& lastModified);
|
||||||
|
|
||||||
void poolConnection();
|
void poolConnection();
|
||||||
|
|
||||||
|
void onDryRunFileFound();
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal();
|
bool executeInternal();
|
||||||
|
|
||||||
|
|
|
@ -369,6 +369,16 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_HTTP);
|
op->addTag(TAG_HTTP);
|
||||||
handlers.push_back(op);
|
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
|
SharedHandle<OptionHandler> op(new UnitNumberOptionHandler
|
||||||
(PREF_LOWEST_SPEED_LIMIT,
|
(PREF_LOWEST_SPEED_LIMIT,
|
||||||
|
|
|
@ -144,9 +144,10 @@ RequestGroup::RequestGroup(const Option* option,
|
||||||
// and add this list.
|
// and add this list.
|
||||||
// ACCEPT_METALINK is used for `transparent metalink'.
|
// ACCEPT_METALINK is used for `transparent metalink'.
|
||||||
addAcceptType(ACCEPT_METALINK);
|
addAcceptType(ACCEPT_METALINK);
|
||||||
|
if(!_option->getAsBool(PREF_DRY_RUN)) {
|
||||||
initializePreDownloadHandler();
|
initializePreDownloadHandler();
|
||||||
initializePostDownloadHandler();
|
initializePostDownloadHandler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestGroup::~RequestGroup() {}
|
RequestGroup::~RequestGroup() {}
|
||||||
|
@ -204,6 +205,11 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
|
||||||
{
|
{
|
||||||
BtContextHandle btContext = dynamic_pointer_cast<BtContext>(_downloadContext);
|
BtContextHandle btContext = dynamic_pointer_cast<BtContext>(_downloadContext);
|
||||||
if(!btContext.isNull()) {
|
if(!btContext.isNull()) {
|
||||||
|
if(_option->getAsBool(PREF_DRY_RUN)) {
|
||||||
|
throw DownloadFailureException
|
||||||
|
("Cancel BitTorrent download in dry-run context.");
|
||||||
|
}
|
||||||
|
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
||||||
throw DownloadFailureException
|
throw DownloadFailureException
|
||||||
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
|
@ -328,7 +334,8 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
// TODO I assume here when totallength is set to DownloadContext and it is
|
// TODO I assume here when totallength is set to DownloadContext and it is
|
||||||
// not 0, then filepath is also set DownloadContext correctly....
|
// 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);
|
createNextCommand(commands, e, 1, method);
|
||||||
}else {
|
}else {
|
||||||
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
||||||
|
|
|
@ -317,7 +317,8 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||||
configureRequestGroup(groupToAdd);
|
configureRequestGroup(groupToAdd);
|
||||||
Commands commands;
|
Commands commands;
|
||||||
createInitialCommand(groupToAdd, commands, e,
|
createInitialCommand(groupToAdd, commands, e,
|
||||||
_option->getAsBool(PREF_USE_HEAD));
|
_option->getAsBool(PREF_USE_HEAD)||
|
||||||
|
_option->getAsBool(PREF_DRY_RUN));
|
||||||
_requestGroups.push_back(groupToAdd);
|
_requestGroups.push_back(groupToAdd);
|
||||||
++count;
|
++count;
|
||||||
e->addCommand(commands);
|
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");
|
const std::string PREF_ENABLE_HTTP_SERVER("enable-http-server");
|
||||||
// value: true | false
|
// value: true | false
|
||||||
const std::string PREF_RESET_URI("reset-uri");
|
const std::string PREF_RESET_URI("reset-uri");
|
||||||
|
// value: true | false
|
||||||
|
const std::string PREF_DRY_RUN("dry-run");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* FTP related preferences
|
||||||
|
|
|
@ -162,6 +162,8 @@ extern const std::string PREF_HTTP_SERVER_LISTEN_PORT;
|
||||||
extern const std::string PREF_ENABLE_HTTP_SERVER;
|
extern const std::string PREF_ENABLE_HTTP_SERVER;
|
||||||
// value: true | false
|
// value: true | false
|
||||||
extern const std::string PREF_RESET_URI;
|
extern const std::string PREF_RESET_URI;
|
||||||
|
// value: true | false
|
||||||
|
extern const std::string PREF_DRY_RUN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP related preferences
|
* 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"\
|
" PATH is a relative path to the path specified in\n"\
|
||||||
" --dir option. You can use this option multiple\n"\
|
" --dir option. You can use this option multiple\n"\
|
||||||
" times.")
|
" 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