diff options
-rw-r--r-- | networking/ftpgetput.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index a23c64af1..44e91c37a 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -174,16 +174,9 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
174 | filesize = atol(buf + 4); | 174 | filesize = atol(buf + 4); |
175 | } | 175 | } |
176 | 176 | ||
177 | /* only make a local file if we know that one exists on the remote server */ | ||
178 | if (do_continue) { | ||
179 | fd_local = xopen(local_file, O_APPEND | O_WRONLY); | ||
180 | } else { | ||
181 | fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); | ||
182 | } | ||
183 | |||
184 | if (do_continue) { | 177 | if (do_continue) { |
185 | struct stat sbuf; | 178 | struct stat sbuf; |
186 | if (fstat(fd_local, &sbuf) < 0) { | 179 | if (lstat(local_file, &sbuf) < 0) { |
187 | perror_msg_and_die("fstat()"); | 180 | perror_msg_and_die("fstat()"); |
188 | } | 181 | } |
189 | if (sbuf.st_size > 0) { | 182 | if (sbuf.st_size > 0) { |
@@ -206,6 +199,13 @@ static int ftp_recieve(FILE *control_stream, const char *host, const char *local | |||
206 | error_msg_and_die("RETR error: %s", buf + 4); | 199 | error_msg_and_die("RETR error: %s", buf + 4); |
207 | } | 200 | } |
208 | 201 | ||
202 | /* only make a local file if we know that one exists on the remote server */ | ||
203 | if (do_continue) { | ||
204 | fd_local = xopen(local_file, O_APPEND | O_WRONLY); | ||
205 | } else { | ||
206 | fd_local = xopen(local_file, O_CREAT | O_TRUNC | O_WRONLY); | ||
207 | } | ||
208 | |||
209 | /* Copy the file */ | 209 | /* Copy the file */ |
210 | if (copyfd(fd_data, fd_local, filesize) == -1) { | 210 | if (copyfd(fd_data, fd_local, filesize) == -1) { |
211 | exit(EXIT_FAILURE); | 211 | exit(EXIT_FAILURE); |