Pārlūkot izejas kodu

2007-12-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Fixed the bug#1841757: aria2 will connect to server to only get
	file size.
	* src/StreamFileAllocationEntry.cc
	* src/option_processing.cc
	* src/HttpResponseCommand.cc: Now reuse connection in segmented
	downloads.
	* src/FtpNegotiationCommand.cc
	
	Suppressed wrong message when finding PreDownloadHandler
	* src/RequestGroup.cc
Tatsuhiro Tsujikawa 18 gadi atpakaļ
vecāks
revīzija
d56dddd553

+ 14 - 1
ChangeLog

@@ -1,3 +1,16 @@
+2007-12-01  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Fixed the bug#1841757: aria2 will connect to server to only get
+	file size.
+	* src/StreamFileAllocationEntry.cc
+	* src/option_processing.cc
+	* src/HttpResponseCommand.cc: Now reuse connection in segmented
+	downloads.
+	* src/FtpNegotiationCommand.cc
+	
+	Suppressed wrong message when finding PreDownloadHandler
+	* src/RequestGroup.cc
+	
 2007-11-29  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Updated usage
@@ -20,7 +33,7 @@
 	* test/MetaFileUtilTest.cc
 	* test/PStringBuildVisitorTest.cc
 	
-	Fixed bug: --check-integrity dones't work for multi file torrent.
+	Fixed bug: --check-integrity doesn't work for multi file torrent.
 	* src/RequestGroup.cc
 	* src/BtCheckIntegrityEntry.cc
 	

+ 14 - 3
src/FtpNegotiationCommand.cc

@@ -76,8 +76,15 @@ bool FtpNegotiationCommand::executeInternal() {
     command->setLowestDownloadSpeedLimit(e->option->getAsInt(PREF_LOWEST_SPEED_LIMIT));
     e->commands.push_back(command);
     return true;
-  } else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED || sequence == SEQ_FILE_PREPARATION) {
+  } else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
     return true;
+  } else if(sequence == SEQ_FILE_PREPARATION) {
+    if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
+      sequence = SEQ_SEND_PASV;
+    } else {
+      sequence = SEQ_SEND_PORT;
+    }
+    return false;
   } else {
     e->commands.push_back(this);
     return false;
@@ -228,10 +235,14 @@ bool FtpNegotiationCommand::recvSize() {
       return false;
     }
     _requestGroup->loadAndOpenFile(infoFile);
-    prepareForNextAction();
+
+    prepareForNextAction(this);
     
     sequence = SEQ_FILE_PREPARATION;
-    e->noWait = true;
+    disableReadCheckSocket();
+    setWriteCheckSocket(dataSocket);
+
+    //e->noWait = true;
     return false;
   } else {
     _requestGroup->validateTotalLength(size);

+ 3 - 1
src/HttpResponseCommand.cc

@@ -132,7 +132,9 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
   try {
     _requestGroup->loadAndOpenFile(infoFile);
     File file(_requestGroup->getFilePath());
-    if(_requestGroup->getRemainingUris().empty() && !file.exists()) {
+
+    SegmentHandle segment = _requestGroup->getSegmentMan()->getSegment(cuid, 0);
+    if(!segment.isNull() && segment->getPositionToWrite() == 0) {
       command = createHttpDownloadCommand(httpResponse);
     }
     prepareForNextAction(command);

+ 1 - 1
src/RequestGroup.cc

@@ -566,7 +566,7 @@ void RequestGroup::preDownloadProcessing()
 	itr != _preDownloadHandlers.end(); ++itr) {
       if((*itr)->canHandle(this)) {
 	(*itr)->execute(this);
-	break;
+	return;
       }
     }
   } catch(RecoverableException* ex) {

+ 3 - 0
src/StreamFileAllocationEntry.cc

@@ -57,6 +57,9 @@ Commands StreamFileAllocationEntry::prepareForNextAction(DownloadEngine* e)
   if(_timer.difference() <= e->option->getAsInt(PREF_DIRECT_DOWNLOAD_TIMEOUT) &&
      _nextCommand) {
     commands.push_back(popNextCommand());
+    // try remaining uris
+    Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1);
+    copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands));
   } else {
     if(_currentRequest.isNull()) {
       commands = _requestGroup->createNextCommandWithAdj(e, 0);

+ 1 - 1
src/option_processing.cc

@@ -118,7 +118,7 @@ Option* option_processing(int argc, char* const argv[])
   op->put(PREF_USER_AGENT, "aria2");
   op->put(PREF_NO_NETRC, V_FALSE);
   op->put(PREF_MAX_CONCURRENT_DOWNLOADS, "5");
-  op->put(PREF_DIRECT_DOWNLOAD_TIMEOUT, "15");
+  op->put(PREF_DIRECT_DOWNLOAD_TIMEOUT, "300");
   op->put(PREF_FORCE_SEQUENTIAL, V_FALSE);
   op->put(PREF_AUTO_FILE_RENAMING, V_TRUE);
   op->put(PREF_PARAMETERIZED_URI, V_FALSE);