Ver código fonte

2008-06-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	If FTP server returns negative response with REST raw command 
and
	requested range is not 0, throw exception. If requested range is 
0,
	continue download a file from 0 byte.
	* src/FtpNegotiationCommand.cc
	* src/FtpNegotiationCommand.h
Tatsuhiro Tsujikawa 17 anos atrás
pai
commit
68b5ae7d86
3 arquivos alterados com 16 adições e 5 exclusões
  1. 8 0
      ChangeLog
  2. 7 4
      src/FtpNegotiationCommand.cc
  3. 1 1
      src/FtpNegotiationCommand.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-06-24  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	If FTP server returns negative response with REST raw command and
+	requested range is not 0, throw exception. If requested range is 0,
+	continue download a file from 0 byte.
+	* src/FtpNegotiationCommand.cc
+	* src/FtpNegotiationCommand.h
+
 2008-06-24  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Supported FTP server which don't recognize SIZE raw command.

+ 7 - 4
src/FtpNegotiationCommand.cc

@@ -383,14 +383,17 @@ bool FtpNegotiationCommand::sendRest(const SegmentHandle& segment) {
   return false;
 }
 
-bool FtpNegotiationCommand::recvRest() {
+bool FtpNegotiationCommand::recvRest(const SharedHandle<Segment>& segment) {
   unsigned int status = ftp->receiveResponse();
   if(status == 0) {
     return false;
   }
-  // TODO if we recieve negative response, then we set _requestGroup->getSegmentMan()->splittable = false, and continue.
+  // If we recieve negative response and requested file position is not 0,
+  // then throw exception here.
   if(status != 350) {
-    throw DlAbortEx(StringFormat(EX_BAD_STATUS, status).str());
+    if(!segment.isNull() && segment->getPositionToWrite() != 0) {
+      throw DlAbortEx("FTP server doesn't support resuming.");
+    }
   }
   sequence = SEQ_SEND_RETR;
   return true;
@@ -480,7 +483,7 @@ bool FtpNegotiationCommand::processSequence(const SegmentHandle& segment) {
   case SEQ_SEND_REST:
     return sendRest(segment);
   case SEQ_RECV_REST:
-    return recvRest();
+    return recvRest(segment);
   case SEQ_SEND_RETR:
     return sendRetr();
   case SEQ_RECV_RETR:

+ 1 - 1
src/FtpNegotiationCommand.h

@@ -92,7 +92,7 @@ private:
   bool recvPasv();
   bool sendRest(const SharedHandle<Segment>& segment);
   bool sendRestPasv(const SharedHandle<Segment>& segment);
-  bool recvRest();
+  bool recvRest(const SharedHandle<Segment>& segment);
   bool sendRetr();
   bool recvRetr();
   bool waitConnection();