home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / wget153.zip / os2 / wget-1.5.3-mirror.diff < prev    next >
Text File  |  1998-09-22  |  6KB  |  164 lines

  1. diff -u wget-1.5.3/src/http.c wget-1.5.3-new/src/http.c
  2. --- wget-1.5.3/src/http.c    Thu Sep 10 19:14:44 1998
  3. +++ wget-1.5.3-new/src/http.c    Wed Sep 23 00:55:37 1998
  4. @@ -841,6 +841,10 @@
  5.  
  6.    int count;
  7.    int use_ts, got_head = 0;    /* time-stamping info */
  8. +  int size_changes;        /* 0 - size not changed
  9. +                   1 - size changed
  10. +                   2 - size changed but --time-only */
  11. +  int scratch = 0;        /* do not continue, overwrite older local */
  12.    char *tms, *suf, *locf, *tmrate;
  13.    uerr_t err;
  14.    time_t tml = -1, tmr = -1;    /* local and remote time-stamps */
  15. @@ -938,7 +942,7 @@
  16.        /* Assume no restarting.  */
  17.        hstat.restval = 0L;
  18.        /* Decide whether or not to restart.  */
  19. -      if (((count > 1 && (*dt & ACCEPTRANGES)) || opt.always_rest)
  20. +      if (((count > 1 && (*dt & ACCEPTRANGES)) || opt.always_rest) && !scratch
  21.        && file_exists_p (u->local))
  22.      if (stat (u->local, &st) == 0)
  23.        hstat.restval = st.st_size;
  24. @@ -950,6 +954,7 @@
  25.  
  26.        /* Try fetching the document, or at least its head.  :-) */
  27.        err = gethttp (u, &hstat, dt);
  28. +      scratch=0;
  29.        /* Time?  */
  30.        tms = time_str (NULL);
  31.        /* Get the new location (with or without the redirection).  */
  32. @@ -1056,12 +1061,40 @@
  33.            FREEHSTAT (hstat);
  34.            return RETROK;
  35.          }
  36. -          else if (tml >= tmr)
  37. -        logprintf (LOG_VERBOSE, _("\
  38. -The sizes do not match (local %ld), retrieving.\n"), local_size);
  39. -          else
  40. -        logputs (LOG_VERBOSE,
  41. -             _("Remote file is newer, retrieving.\n"));
  42. +          else {
  43. +        /* size changed ? */
  44. +        if (local_size != hstat.contlen) {
  45. +          logprintf (LOG_VERBOSE, _("\
  46. +The sizes do not match (local %ld)"), local_size);
  47. +          /* ignore size changes ? */
  48. +          if (opt.time_only) {
  49. +            logprintf (LOG_VERBOSE, _(", ignored.\n"));
  50. +            size_changes = 2;
  51. +          } else {
  52. +            logprintf (LOG_VERBOSE, _(", retrieving.\n"));
  53. +            size_changes = 1;
  54. +          }
  55. +        } else
  56. +          size_changes = 0;
  57. +        /* remote newer ? */
  58. +        if (tml < tmr) {
  59. +          if (opt.rewrite_older) {
  60. +            logputs (LOG_VERBOSE,
  61. +                 _("Remote file is newer, overwriting.\n"));
  62. +            scratch = !scratch;
  63. +          } else
  64. +            /* if we said 'retrieving' - no new messages */
  65. +            if (size_changes != 1)
  66. +              logputs (LOG_VERBOSE,
  67. +                   _("Remote file is newer, retrieving.\n"));
  68. +        } else
  69. +          if (size_changes != 1) {
  70. +            /* local newer and no retrieving due to size changes
  71. +               - no retrieve */
  72. +            FREEHSTAT (hstat);
  73. +            return RETROK;
  74. +          }
  75. +          }
  76.          }
  77.        FREEHSTAT (hstat);
  78.        continue;
  79. diff -u wget-1.5.3/src/init.c wget-1.5.3-new/src/init.c
  80. --- wget-1.5.3/src/init.c    Fri Sep 11 06:20:23 1998
  81. +++ wget-1.5.3-new/src/init.c    Wed Sep 23 00:56:30 1998
  82. @@ -137,12 +137,14 @@
  83.    { "relativeonly",    &opt.relative_only,    cmd_boolean },
  84.    { "removelisting",    &opt.remove_listing,    cmd_boolean },
  85.    { "retrsymlinks",    &opt.retr_symlinks,    cmd_boolean },
  86. +  { "rewriteolder",    &opt.rewrite_older,    cmd_boolean },
  87.    { "robots",        &opt.use_robots,    cmd_boolean },
  88.    { "saveheaders",    &opt.save_headers,    cmd_boolean },
  89.    { "serverresponse",    &opt.server_response,    cmd_boolean },
  90.    { "simplehostcheck",    &opt.simple_check,    cmd_boolean },
  91.    { "spanhosts",    &opt.spanhost,        cmd_boolean },
  92.    { "spider",        &opt.spider,        cmd_boolean },
  93. +  { "timeonly",        &opt.time_only,        cmd_boolean },
  94.    { "timeout",        &opt.timeout,        cmd_time },
  95.    { "timestamping",    &opt.timestamping,    cmd_boolean },
  96.    { "tries",        &opt.ntry,        cmd_number_inf },
  97. diff -u wget-1.5.3/src/main.c wget-1.5.3-new/src/main.c
  98. --- wget-1.5.3/src/main.c    Fri Sep 11 07:41:53 1998
  99. +++ wget-1.5.3-new/src/main.c    Wed Sep 23 00:58:55 1998
  100. @@ -138,6 +138,8 @@
  101.    -c,  --continue               restart getting an existing file.\n\
  102.         --dot-style=STYLE        set retrieval display style.\n\
  103.    -N,  --timestamping           don\'t retrieve files if older than local.\n\
  104. +       --time-only              retrieve only newer files, ignore size.\n\
  105. +       --rewrite-older          overwrite local file if remote file newer.\n\
  106.    -S,  --server-response        print server response.\n\
  107.         --spider                 don\'t download anything.\n\
  108.    -T,  --timeout=SECONDS        set the read timeout to SECONDS.\n\
  109. @@ -223,11 +225,13 @@
  110.      { "recursive", no_argument, NULL, 'r' },
  111.      { "relative", no_argument, NULL, 'L' },
  112.      { "retr-symlinks", no_argument, NULL, 9 },
  113. +    { "rewrite-older", no_argument, NULL, 25 },
  114.      { "save-headers", no_argument, NULL, 's' },
  115.      { "server-response", no_argument, NULL, 'S' },
  116.      { "span-hosts", no_argument, NULL, 'H' },
  117.      { "spider", no_argument, NULL, 4 },
  118.      { "timestamping", no_argument, NULL, 'N' },
  119. +    { "time-only", no_argument, NULL, 24 },
  120.      { "verbose", no_argument, NULL, 'v' },
  121.      { "version", no_argument, NULL, 'V' },
  122.  
  123. @@ -378,6 +382,12 @@
  124.      case 'N':
  125.        setval ("timestamping", "on");
  126.        break;
  127. +    case 24:
  128. +      setval ("timeonly", "on");
  129. +      break;
  130. +    case 25:
  131. +      setval ("rewriteolder", "on");
  132. +      break;
  133.      case 'S':
  134.        setval ("serverresponse", "on");
  135.        break;
  136. @@ -576,6 +586,13 @@
  137.      {
  138.        printf (_("\
  139.  Can't timestamp and not clobber old files at the same time.\n"));
  140. +      print_usage ();
  141. +      exit (1);
  142. +    }
  143. +  if (!opt.timestamping && (opt.time_only || opt.rewrite_older))
  144. +    {
  145. +      printf (_("\
  146. +Timestamping should be turned on when using --time-only or --rewrite-older.\n"));
  147.        print_usage ();
  148.        exit (1);
  149.      }
  150. diff -u wget-1.5.3/src/options.h wget-1.5.3-new/src/options.h
  151. --- wget-1.5.3/src/options.h    Wed Apr 29 03:29:40 1998
  152. +++ wget-1.5.3-new/src/options.h    Wed Sep 23 00:59:48 1998
  153. @@ -113,6 +113,10 @@
  154.  #endif /* DEBUG */
  155.  
  156.    int timestamping;        /* Whether to use time-stamping. */
  157. +  int rewrite_older;        /* Overwrite local If remote newer,
  158. +                   don't continue */
  159. +  int time_only;        /* Retrieve only if remote newer,
  160. +                   ignore filesize */
  161.    int backups;            /* Are backups made? */
  162.  
  163.    char *useragent;        /* Naughty User-Agent, which can be
  164.