2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Removed unused method argument.
	* src/CreateRequestCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
	* src/TrackerWatcherCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2009-07-04 14:32:53 +00:00
parent a7c222b8ab
commit 3f3e9c0ff0
6 changed files with 27 additions and 30 deletions

View File

@ -1,3 +1,12 @@
2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed unused method argument.
* src/CreateRequestCommand.cc
* src/RequestGroup.cc
* src/RequestGroup.h
* src/RequestGroupMan.cc
* src/TrackerWatcherCommand.cc
2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made URI reusing function work. Made URI reusing function work.

View File

@ -75,8 +75,10 @@ bool CreateRequestCommand::executeInternal()
getOption()->get(PREF_REFERER), getOption()->get(PREF_REFERER),
// Don't use HEAD request when file // Don't use HEAD request when file
// size is known. // size is known.
_fileEntry->getLength() == 0 && // Use HEAD for dry-run mode.
getOption()->getAsBool(PREF_USE_HEAD)? (_fileEntry->getLength() == 0 &&
getOption()->getAsBool(PREF_USE_HEAD)) ||
getOption()->getAsBool(PREF_DRY_RUN)?
Request::METHOD_HEAD:Request::METHOD_GET); Request::METHOD_HEAD:Request::METHOD_GET);
if(req.isNull()) { if(req.isNull()) {
if(!_requestGroup->getSegmentMan().isNull()) { if(!_requestGroup->getSegmentMan().isNull()) {

View File

@ -196,8 +196,7 @@ void RequestGroup::closeFile()
} }
void RequestGroup::createInitialCommand(std::deque<Command*>& commands, void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
DownloadEngine* e, DownloadEngine* e)
const std::string& method)
{ {
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
{ {
@ -351,7 +350,7 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
// not 0, then filepath is also set DownloadContext correctly.... // not 0, then filepath is also set DownloadContext correctly....
if(_option->getAsBool(PREF_DRY_RUN) || if(_option->getAsBool(PREF_DRY_RUN) ||
_downloadContext->getTotalLength() == 0) { _downloadContext->getTotalLength() == 0) {
createNextCommand(commands, e, 1, method); createNextCommand(commands, e, 1);
}else { }else {
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) { if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
throw DOWNLOAD_FAILURE_EXCEPTION throw DOWNLOAD_FAILURE_EXCEPTION
@ -596,8 +595,7 @@ void RequestGroup::createNextCommandWithAdj(std::deque<Command*>& commands,
void RequestGroup::createNextCommand(std::deque<Command*>& commands, void RequestGroup::createNextCommand(std::deque<Command*>& commands,
DownloadEngine* e, DownloadEngine* e,
unsigned int numCommand, unsigned int numCommand)
const std::string& method)
{ {
// TODO1.5 The following block should be moved into FileEntry // TODO1.5 The following block should be moved into FileEntry
// if(_option->getAsBool(PREF_REUSE_URI) && _uris.empty()) { // if(_option->getAsBool(PREF_REUSE_URI) && _uris.empty()) {

View File

@ -183,21 +183,15 @@ public:
// Returns first bootstrap commands to initiate a download. // Returns first bootstrap commands to initiate a download.
// If this is HTTP/FTP download and file size is unknown, only 1 command // If this is HTTP/FTP download and file size is unknown, only 1 command
// (usually, HttpInitiateConnection or FtpInitiateConnection) will be created // (usually, HttpInitiateConnection or FtpInitiateConnection) will be created.
// with its Request object having Requet::METHOD_HEAD in its method.
// This behavior can be changed by providing 3rd argument.
// The method has effect only for using HTTP request including FTP via HTTP
// proxy.
void createInitialCommand(std::deque<Command*>& commands, void createInitialCommand(std::deque<Command*>& commands,
DownloadEngine* e, DownloadEngine* e);
const std::string& method = Request::METHOD_HEAD);
void createNextCommandWithAdj(std::deque<Command*>& commands, void createNextCommandWithAdj(std::deque<Command*>& commands,
DownloadEngine* e, int numAdj); DownloadEngine* e, int numAdj);
void createNextCommand(std::deque<Command*>& commands, void createNextCommand(std::deque<Command*>& commands,
DownloadEngine* e, unsigned int numCommand, DownloadEngine* e, unsigned int numCommand);
const std::string& method = Request::METHOD_GET);
bool downloadFinished() const; bool downloadFinished() const;

View File

@ -428,13 +428,9 @@ void RequestGroupMan::configureRequestGroup
static void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup, static void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
std::deque<Command*>& commands, std::deque<Command*>& commands,
DownloadEngine* e, DownloadEngine* e)
bool useHead)
{ {
requestGroup->createInitialCommand(commands, e, requestGroup->createInitialCommand(commands, e);
useHead ?
Request::METHOD_HEAD :
Request::METHOD_GET);
} }
void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
@ -456,9 +452,7 @@ 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_DRY_RUN));
_requestGroups.push_back(groupToAdd); _requestGroups.push_back(groupToAdd);
++count; ++count;
e->addCommand(commands); e->addCommand(commands);
@ -486,9 +480,7 @@ void RequestGroupMan::getInitialCommands(std::deque<Command*>& commands,
try { try {
if((*itr)->isDependencyResolved()) { if((*itr)->isDependencyResolved()) {
configureRequestGroup(*itr); configureRequestGroup(*itr);
createInitialCommand(*itr, commands, e, createInitialCommand(*itr, commands, e);
// TODO1.5 We need PREF_DRY_RUN here?
_option->getAsBool(PREF_USE_HEAD));
executeStartHook(*itr, e->option); executeStartHook(*itr, e->option);
++itr; ++itr;
} else { } else {

View File

@ -96,8 +96,7 @@ bool TrackerWatcherCommand::execute() {
_trackerRequestGroup = createAnnounce(); _trackerRequestGroup = createAnnounce();
if(!_trackerRequestGroup.isNull()) { if(!_trackerRequestGroup.isNull()) {
std::deque<Command*> commands; std::deque<Command*> commands;
_trackerRequestGroup->createInitialCommand(commands, e, _trackerRequestGroup->createInitialCommand(commands, e);
Request::METHOD_GET);
e->addCommand(commands); e->addCommand(commands);
logger->debug("added tracker request command"); logger->debug("added tracker request command");
} }
@ -210,6 +209,9 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
logger->debug("This is single-tracker announce."); logger->debug("This is single-tracker announce.");
rg->getOption()->put(PREF_MAX_TRIES, "5"); rg->getOption()->put(PREF_MAX_TRIES, "5");
} }
// TODO When dry-run mode becomes available in BitTorrent, set
// PREF_DRY_RUN=false too.
rg->getOption()->put(PREF_USE_HEAD, V_FALSE);
static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]"); static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]");
SharedHandle<DownloadContext> dctx SharedHandle<DownloadContext> dctx