From f1d534cd8c7213de76f58eb218ff34feeda7091f Mon Sep 17 00:00:00 2001 From: hniksic Date: Tue, 3 Apr 2001 05:24:49 -0700 Subject: [PATCH] [svn] Make `-c' and `-O' work together. Published in . --- src/ChangeLog | 7 +++++++ src/ftp.c | 7 +++++-- src/http.c | 7 +++++-- src/main.c | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 99709be5..d03d40ae 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2001-04-02 Hrvoje Niksic + + * http.c (http_loop): Ditto. + + * ftp.c (ftp_loop_internal): Made the check whether to continue + retrieval `-O'-friendly. + 2001-04-02 Hrvoje Niksic * netrc.c (parse_netrc): Don't trim the line endings explicitly; diff --git a/src/ftp.c b/src/ftp.c index 0cdbcc1d..e9b68609 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -825,6 +825,9 @@ Error in server response, closing control connection.\n")); /* This will silently fail for streams that don't correspond to regular files, but that's OK. */ rewind (fp); + /* ftruncate is needed because opt.dfp is opened in append + mode if opt.always_rest is set. */ + ftruncate (fileno (fp), 0); clearerr (fp); } } @@ -1033,8 +1036,8 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con) restval = 0L; if ((count > 1 || opt.always_rest) && !(con->cmd & DO_LIST) - && file_exists_p (u->local)) - if (stat (u->local, &st) == 0) + && file_exists_p (locf)) + if (stat (locf, &st) == 0 && S_ISREG (st.st_mode)) restval = st.st_size; /* Get the current time string. */ tms = time_str (NULL); diff --git a/src/http.c b/src/http.c index 4c65d677..7c40d060 100644 --- a/src/http.c +++ b/src/http.c @@ -1305,6 +1305,9 @@ Accept: %s\r\n\ /* This will silently fail for streams that don't correspond to regular files, but that's OK. */ rewind (fp); + /* ftruncate is needed because opt.dfp is opened in append + mode if opt.always_rest is set. */ + ftruncate (fileno (fp), 0); clearerr (fp); } } @@ -1487,8 +1490,8 @@ File `%s' already there, will not retrieve.\n"), u->local); hstat.restval = 0L; /* Decide whether or not to restart. */ if (((count > 1 && (*dt & ACCEPTRANGES)) || opt.always_rest) - && file_exists_p (u->local)) - if (stat (u->local, &st) == 0) + && file_exists_p (locf)) + if (stat (locf, &st) == 0 && S_ISREG (st.st_mode)) hstat.restval = st.st_size; /* Decide whether to send the no-cache directive. */ if (u->proxy && (count > 1 || (opt.proxy_cache == 0))) diff --git a/src/main.c b/src/main.c index 1f5a88aa..34277c47 100644 --- a/src/main.c +++ b/src/main.c @@ -752,7 +752,7 @@ Can't timestamp and not clobber old files at the same time.\n")); else { struct stat st; - opt.dfp = fopen (opt.output_document, "wb"); + opt.dfp = fopen (opt.output_document, opt.always_rest ? "ab" : "wb"); if (opt.dfp == NULL) { perror (opt.output_document); -- 2.39.2