]> sjero.net Git - wget/commitdiff
[svn] Fix -O timestamp bug.
authorhniksic <devnull@localhost>
Mon, 11 Dec 2000 00:47:44 +0000 (16:47 -0800)
committerhniksic <devnull@localhost>
Mon, 11 Dec 2000 00:47:44 +0000 (16:47 -0800)
From <sxs7l57u6o6.fsf@florida.arsdigita.de>.

src/ChangeLog
src/ftp.c
src/http.c
src/main.c
src/options.h

index 1584017096894fc4c7af52052aa5a376040543af..71b318e8be5eaf35087470dc0c069cf9b6f42e0d 100644 (file)
@@ -1,3 +1,8 @@
+2000-12-11  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * http.c (http_loop): Furthermore, touch output_document only if
+       it is known to be an existing regular file.
+
 2000-12-11  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * ftp.c (ftp_retrieve_list): Ditto.
 2000-12-11  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * ftp.c (ftp_retrieve_list): Ditto.
index bb0771cf6fcb62dca74fb312f6f03eefaaedbf30..2b9eb0f267e4b63a60db95ae19e7afe35990aebe 100644 (file)
--- 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))
        {
           && 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);
        }
       else if (f->tstamp == -1)
        logprintf (LOG_NOTQUIET, _("%s: corrupt time-stamp.\n"), u->local);
index 6e103d968f45a0dd0f194010f778d62bd9a854c6..676fef5b7db4a0845d5b7a75380e1aab58ede452 100644 (file)
@@ -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)))))
        {
               ((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.  */
 
        }
       /* End of time-stamping section.  */
 
index 1b85b0b35a9226bd72fe10a0ab987337312ddb1b..221ac5ae3d93824a0407d9112ca0c4f9053a8a24 100644 (file)
@@ -726,12 +726,15 @@ Can't timestamp and not clobber old files at the same time.\n"));
        opt.dfp = stdout;
       else
        {
        opt.dfp = stdout;
       else
        {
+         struct stat st;
          opt.dfp = fopen (opt.output_document, "wb");
          if (opt.dfp == NULL)
            {
              perror (opt.output_document);
              exit (1);
            }
          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;
        }
     }
 
        }
     }
 
index e080adb03000c7609c06dcc07ed57ab31f5770d2..7c1fac51a46f0d58d2c4a4d7cbe8291af6512fb3 100644 (file)
@@ -73,6 +73,9 @@ struct options
                                   FTP. */
   char *output_document;       /* The output file to which the
                                   documents will be printed.  */
                                   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. */
 
   FILE *dfp;                   /* The file pointer to the output
                                   document. */