From d5cd691b121120ec4ff1509f29519e98185fad4d Mon Sep 17 00:00:00 2001 From: hniksic Date: Sun, 10 Dec 2000 16:47:44 -0800 Subject: [PATCH] [svn] Fix -O timestamp bug. From . --- src/ChangeLog | 5 +++++ src/ftp.c | 14 ++++++++++++-- src/http.c | 14 ++++++++++++-- src/main.c | 3 +++ src/options.h | 3 +++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 15840170..71b318e8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2000-12-11 Hrvoje Niksic + + * http.c (http_loop): Furthermore, touch output_document only if + it is known to be an existing regular file. + 2000-12-11 Hrvoje Niksic * ftp.c (ftp_retrieve_list): Ditto. diff --git a/src/ftp.c b/src/ftp.c index bb0771cf..2b9eb0f2 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1370,8 +1370,18 @@ Already have correct symlink %s -> %s\n\n"), && dlthis && file_exists_p (u->local)) { - const char *fl = opt.output_document ? opt.output_document : u->local; - touch (fl, f->tstamp); + /* #### This code repeats in http.c and ftp.c. Move it to a + function! */ + const char *fl = NULL; + if (opt.output_document) + { + if (opt.od_known_regular) + fl = opt.output_document; + } + else + fl = u->local; + if (fl) + touch (fl, f->tstamp); } else if (f->tstamp == -1) logprintf (LOG_NOTQUIET, _("%s: corrupt time-stamp.\n"), u->local); diff --git a/src/http.c b/src/http.c index 6e103d96..676fef5b 100644 --- a/src/http.c +++ b/src/http.c @@ -1533,8 +1533,18 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size); ((hstat.contlen == -1) || (hstat.len >= hstat.contlen && !opt.kill_longer))))) { - const char *fl = opt.output_document ? opt.output_document : u->local; - touch (fl, tmr); + /* #### This code repeats in http.c and ftp.c. Move it to a + function! */ + const char *fl = NULL; + if (opt.output_document) + { + if (opt.od_known_regular) + fl = opt.output_document; + } + else + fl = u->local; + if (fl) + touch (fl, tmr); } /* End of time-stamping section. */ diff --git a/src/main.c b/src/main.c index 1b85b0b3..221ac5ae 100644 --- a/src/main.c +++ b/src/main.c @@ -726,12 +726,15 @@ Can't timestamp and not clobber old files at the same time.\n")); opt.dfp = stdout; else { + struct stat st; opt.dfp = fopen (opt.output_document, "wb"); if (opt.dfp == NULL) { perror (opt.output_document); exit (1); } + if (fstat (fileno (opt.dfp), &st) == 0 && S_ISREG (st.st_mode)) + opt.od_known_regular = 1; } } diff --git a/src/options.h b/src/options.h index e080adb0..7c1fac51 100644 --- a/src/options.h +++ b/src/options.h @@ -73,6 +73,9 @@ struct options FTP. */ char *output_document; /* The output file to which the documents will be printed. */ + int od_known_regular; /* whether output_document is a + regular file we can manipulate, + i.e. not `-' or a device file. */ FILE *dfp; /* The file pointer to the output document. */ -- 2.39.2