when asking for a resumed FTP transfer, even though the entire file has
authorDaniel Stenberg <daniel@haxx.se>
Fri, 11 May 2001 11:38:13 +0000 (11:38 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 11 May 2001 11:38:13 +0000 (11:38 +0000)
already been transfered no longer returns error but instead is OK. The
reasoning behind this is of course that no extra actions need to be taken
and it is as if a transfer had been successfully performed.

lib/ftp.c
lib/urldata.h

index 2629c07fedb9b0b4ac8d09c1409265d65cbca6d3..a2c8455c7104693d1c4bdb979c1cbbad624c03cf 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -655,11 +655,14 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
       failf(data, "Received only partial file");
       return CURLE_PARTIAL_FILE;
     }
-    else if(!data->bits.no_body && (0 == *ftp->bytecountp)) {
+    else if(!conn->bits.resume_done &&
+            !data->bits.no_body &&
+            (0 == *ftp->bytecountp)) {
       failf(data, "No data was received!");
       return CURLE_FTP_COULDNT_RETR_FILE;
     }
   }
+
 #ifdef KRB4
   sec_fflush_fd(conn, conn->secondarysocket);
 #endif
@@ -667,7 +670,7 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
   sclose(conn->secondarysocket);
   conn->secondarysocket = -1;
 
-  if(!data->bits.no_body) {  
+  if(!data->bits.no_body && !conn->bits.resume_done) {  
     /* now let's see what the server says about the transfer we
        just performed: */
     nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
@@ -681,6 +684,8 @@ CURLcode Curl_ftp_done(struct connectdata *conn)
     }
   }
 
+  conn->bits.resume_done = FALSE; /* clean this for next connection */
+
   /* Send any post-transfer QUOTE strings? */
   if(data->postquote) {
     qitem = data->postquote;
@@ -1499,8 +1504,17 @@ again:;
           data->infilesize -= conn->resume_from;
 
           if(data->infilesize <= 0) {
-            failf(data, "File already completely uploaded\n");
-            return CURLE_FTP_COULDNT_STOR_FILE;
+            infof(data, "File already completely uploaded\n");
+
+            /* no data to transfer */
+            result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+            
+            /* Set resume done so that we won't get any error in
+             * Curl_ftp_done() because we didn't transfer the amount of bytes
+             * that the local file file obviously is */
+            conn->bits.resume_done = TRUE; 
+
+            return CURLE_OK;
           }
         }
         /* we've passed, proceed as normal */
@@ -1677,8 +1691,16 @@ again:;
         }
 
        if (downloadsize == 0) {
-         failf(data, "File already complete");
-         return CURLE_ALREADY_COMPLETE;
+          /* no data to transfer */
+          result=Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+         infof(data, "File already completely downloaded\n");
+
+          /* Set resume done so that we won't get any error in Curl_ftp_done()
+           * because we didn't transfer the amount of bytes that the remote
+           * file obviously is */
+          conn->bits.resume_done = TRUE; 
+
+         return CURLE_OK;
        }
        
         /* Set resume file transfer offset */
index fcb1db39ef22dbea3c57b705663d65351f3d4cc4..fa9eb793e436b2507a13f397f9c2eda0c46d28a1 100644 (file)
@@ -188,6 +188,9 @@ struct ConnectBits {
 
   bool use_range;
   bool rangestringalloc; /* the range string is malloc()'ed */
+
+  bool resume_done; /* nothing was transfered, resumed transfer already
+                       complete */
 };
 
 /*