Updated the opening comments to mention how to apply the patch
[rsync/rsync-patches.git] / downdate.diff
1 A patch from Stefan Müller to add the --downdate option, which works
2 in the opposite manner as --update.
3
4 To use this patch, run these commands for a successful build:
5
6     patch -p1 <patches/downdate.diff
7     ./configure                                 (optional if already run)
8     make
9
10 --- old/generator.c
11 +++ new/generator.c
12 @@ -53,6 +53,7 @@ extern int ignore_errors;
13  extern int remove_source_files;
14  extern int delay_updates;
15  extern int update_only;
16 +extern int downdate_only;
17  extern int ignore_existing;
18  extern int ignore_non_existing;
19  extern int inplace;
20 @@ -1144,6 +1145,13 @@ static void recv_generator(char *fname, 
21                 return;
22         }
23  
24 +       if (downdate_only && statret == 0
25 +           && cmp_time(st.st_mtime, file->modtime) < 0) {
26 +               if (verbose > 1)
27 +                       rprintf(FINFO, "%s is older\n", fname);
28 +               return;
29 +       }
30 +
31         fnamecmp = fname;
32         fnamecmp_type = FNAMECMP_FNAME;
33  
34 @@ -1452,7 +1460,7 @@ void generate_files(int f_out, struct fi
35         phase++;
36         csum_length = SUM_LENGTH;
37         max_size = min_size = ignore_existing = ignore_non_existing = 0;
38 -       update_only = always_checksum = size_only = 0;
39 +       downdate_only = update_only = always_checksum = size_only = 0;
40         ignore_times = 1;
41         if (append_mode)  /* resend w/o append mode */
42                 append_mode = -1; /* ... but only longer files */
43 --- old/options.c
44 +++ new/options.c
45 @@ -56,6 +56,7 @@ int preserve_gid = 0;
46  int preserve_times = 0;
47  int omit_dir_times = 0;
48  int update_only = 0;
49 +int downdate_only = 0;
50  int cvs_exclude = 0;
51  int dry_run = 0;
52  int do_xfers = 1;
53 @@ -293,6 +294,7 @@ void usage(enum logcode F)
54    rprintf(F,"     --backup-dir=DIR        make backups into hierarchy based in DIR\n");
55    rprintf(F,"     --suffix=SUFFIX         set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
56    rprintf(F," -u, --update                skip files that are newer on the receiver\n");
57 +  rprintf(F," -w, --downdate              skip files that are older on the receiver\n");
58    rprintf(F,"     --inplace               update destination files in-place (SEE MAN PAGE)\n");
59    rprintf(F,"     --append                append data onto shorter files\n");
60    rprintf(F," -d, --dirs                  transfer directories without recursing\n");
61 @@ -465,6 +467,7 @@ static struct poptOption long_options[] 
62    {"size-only",        0,  POPT_ARG_NONE,   &size_only, 0, 0, 0 },
63    {"one-file-system", 'x', POPT_ARG_NONE,   0, 'x', 0, 0 },
64    {"update",          'u', POPT_ARG_NONE,   &update_only, 0, 0, 0 },
65 +  {"downdate",        'w', POPT_ARG_NONE,   &downdate_only, 0, 0, 0 },
66    {"existing",         0,  POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
67    {"ignore-non-existing",0,POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
68    {"ignore-existing",  0,  POPT_ARG_NONE,   &ignore_existing, 0, 0, 0 },