aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-05-11 11:38:13 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-05-11 11:38:13 +0000
commit11f2464a220d56109265e491d7768ac6aaae4d63 (patch)
tree09208c983a9ebbc1452f2ad5896b94918e156715
parent291075b12f7a357025565978968118bf4f18be5b (diff)
when asking for a resumed FTP transfer, even though the entire file has
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.
-rw-r--r--lib/ftp.c34
-rw-r--r--lib/urldata.h3
2 files changed, 31 insertions, 6 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 2629c07fe..a2c8455c7 100644
--- 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 */
diff --git a/lib/urldata.h b/lib/urldata.h
index fcb1db39e..fa9eb793e 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -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 */
};
/*