David Fritz <[EMAIL PROTECTED]> writes:
> This problem seems to have gone overlooked:
>
> http://www.mail-archive.com/wget%40sunsite.dk/msg06527.html
> http://www.mail-archive.com/wget%40sunsite.dk/msg06560.html
>
> Sorry for not including a patch.
I have attached the patch that should fix this serious problem.
Thanks for your persistence.
>From your previous report:
> Now, [-c] will re-download the whole file and discard bytes util it
> gets to the right position. I think this change deserves explicit
> mention in the NEWS file. There's an entry about the new logic when
> Range requests fail, but I don't think it's obvious that this
> affects -c.
I don't really see how failed Range requests could not affect -c.
Prior to Wget 1.9, a failed Range would cause the retrieval to start
from scratch, which was obviously wrong. I think the new behavior is
the only reasonable thing to do by default.
I'm not sure that it makes sense to provide an option to restore the
1.9 behavior. Since the bytes are being discarded anyway, you can
simply press ^C and try again with a new mirror.
2005-05-17 Hrvoje Niksic <[EMAIL PROTECTED]>
* http.c (http_loop): Don't clobber the file when -c is specified
and the first attempt to retrieve the file fails.
Index: src/http.c
===================================================================
RCS file: /pack/anoncvs/wget/src/http.c,v
retrieving revision 1.187
diff -u -r1.187 http.c
--- src/http.c 2005/05/16 22:01:10 1.187
+++ src/http.c 2005/05/17 08:45:17
@@ -2141,13 +2141,18 @@
*dt &= ~HEAD_ONLY;
/* Decide whether or not to restart. */
- hstat.restval = 0;
- if (count > 1)
- hstat.restval = hstat.len; /* continue where we left off */
- else if (opt.always_rest
- && stat (locf, &st) == 0
- && S_ISREG (st.st_mode))
+ if (opt.always_rest
+ && stat (locf, &st) == 0
+ && S_ISREG (st.st_mode))
+ /* When -c is used, continue from on-disk size. (Can't use
+ hstat.len even if count>1 because we don't want a failed
+ first attempt to clobber existing data.) */
hstat.restval = st.st_size;
+ else if (count > 1)
+ /* otherwise, continue where the previous try left off */
+ hstat.restval = hstat.len;
+ else
+ hstat.restval = 0;
/* Decide whether to send the no-cache directive. We send it in
two cases: