Hi,

I am forwarding Debian wishlist bug #32712
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=32712&repeatmerged=yes

----


Mirrors default behaviour when running in mirror or time stamp mode is
to set both atime and mtime of the down loaded file to the remote
files mtime. This causes problems with automatic cleanup scripts, such
as tmpreaper, that look at the files atime to determine which files to
delete.

The following patch fixes this problem by changing the wgets default
behaviour to setting atime to the current time instead. It also adds a
switch to restore the old behaviour for those that need it.

-----

The patch is for an old version, here it is

diff -ur wget-1.5.3/src/init.c wget-1.5.3sb/src/init.c
--- wget-1.5.3/src/init.c       Fri Sep 11 02:20:23 1998
+++ wget-1.5.3sb/src/init.c     Fri Jan 29 17:54:01 1999
@@ -140,6 +140,7 @@
   { "robots",          &opt.use_robots,        cmd_boolean },
   { "saveheaders",     &opt.save_headers,      cmd_boolean },
   { "serverresponse",  &opt.server_response,   cmd_boolean },
+  { "setatimeeqtomtime",&opt.set_atime_eq_mtime,cmd_boolean },
   { "simplehostcheck", &opt.simple_check,      cmd_boolean },
   { "spanhosts",       &opt.spanhost,          cmd_boolean },
   { "spider",          &opt.spider,            cmd_boolean },
diff -ur wget-1.5.3/src/main.c wget-1.5.3sb/src/main.c
--- wget-1.5.3/src/main.c       Fri Sep 11 03:41:53 1998
+++ wget-1.5.3sb/src/main.c     Fri Jan 29 17:00:34 1999
@@ -138,6 +138,7 @@
   -c,  --continue               restart getting an existing file.\n\
        --dot-style=STYLE        set retrieval display style.\n\
   -N,  --timestamping           don\'t retrieve files if older than local.\n\
+       --set-atime-eq-to-mtime  when timestamping, also set atime equal to mtime.\n\
   -S,  --server-response        print server response.\n\
        --spider                 don\'t download anything.\n\
   -T,  --timeout=SECONDS        set the read timeout to SECONDS.\n\
@@ -228,6 +229,7 @@
     { "span-hosts", no_argument, NULL, 'H' },
     { "spider", no_argument, NULL, 4 },
     { "timestamping", no_argument, NULL, 'N' },
+    { "set-atime-eq-to-mtime", no_argument, NULL, 246},
     { "verbose", no_argument, NULL, 'v' },
     { "version", no_argument, NULL, 'V' },
 
@@ -406,6 +408,9 @@
          break;
        case 'x':
          setval ("dirstruct", "on");
+         break;
+       case 246:
+         setval ("setatimeeqtomtime", "on");
          break;
 
          /* Options accepting an argument: */
diff -ur wget-1.5.3/src/options.h wget-1.5.3sb/src/options.h
--- wget-1.5.3/src/options.h    Tue Apr 28 23:29:40 1998
+++ wget-1.5.3sb/src/options.h  Thu Jan 28 18:55:50 1999
@@ -132,6 +132,9 @@
 
   int delete_after;            /* Whether the files will be deleted
                                   after download. */
+  int set_atime_eq_mtime;      /* Whether to make atime eqal to mtime
+                                  when setting timestamping after
+                                  download.*/
 };
 
 #ifndef OPTIONS_DEFINED_HERE
diff -ur wget-1.5.3/src/utils.c wget-1.5.3sb/src/utils.c
--- wget-1.5.3/src/utils.c      Thu Jan 28 19:08:21 1999
+++ wget-1.5.3sb/src/utils.c    Fri Jan 29 16:48:32 1999
@@ -35,6 +35,7 @@
 # include <pwd.h>
 #endif
 #include <limits.h>
+#include <time.h>
 #ifdef HAVE_UTIME_H
 # include <utime.h>
 #endif
@@ -397,17 +398,29 @@
     }
 }
 
-/* "Touch" FILE, i.e. make its atime and mtime equal to the time
-   specified with TM.  */
+/* "Touch" FILE, i.e. make its mtime and possibly atime equal to the time
+   specified with TM. If the atime is set to the current time. */
 void
 touch (const char *file, time_t tm)
 {
 #ifdef HAVE_STRUCT_UTIMBUF
   struct utimbuf times;
-  times.actime = times.modtime = tm;
+  if(opt.set_atime_eq_mtime) 
+    times.actime = times.modtime = tm;
+  else {
+    times.modtime = tm;
+    /* Set the accesstime to the current time. */
+    times.actime = time(NULL);
+  }
 #else
   time_t times[2];
-  times[0] = times[1] = tm;
+  if(opt.set_atime_eq_mtime) 
+    times[0] = times[1] = tm;
+  else {
+    times[1] = tm;
+    /* Set the accesstime to the current time. */
+    times[0] = time(NULL);
+  }
 #endif
 
   if (utime (file, &times) == -1)

any comments welcome. Please keep [EMAIL PROTECTED] CC'ed.

-- 
Guillaume Morin <[EMAIL PROTECTED]>

                       Alcôve - L'informatique est libre
                           http://www.alcove.com/fr/

Reply via email to