A patch from Stefan Müller.
[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 --- old/generator.c
5 +++ new/generator.c
6 @@ -53,6 +53,7 @@ extern int ignore_errors;
7  extern int remove_sent_files;
8  extern int delay_updates;
9  extern int update_only;
10 +extern int downdate_only;
11  extern int ignore_existing;
12  extern int ignore_non_existing;
13  extern int inplace;
14 @@ -1133,6 +1134,13 @@ static void recv_generator(char *fname, 
15                 return;
16         }
17  
18 +       if (downdate_only && statret == 0
19 +           && cmp_time(st.st_mtime, file->modtime) < 0) {
20 +               if (verbose > 1)
21 +                       rprintf(FINFO, "%s is older\n", fname);
22 +               return;
23 +       }
24 +
25         fnamecmp = fname;
26         fnamecmp_type = FNAMECMP_FNAME;
27  
28 @@ -1430,7 +1438,7 @@ void generate_files(int f_out, struct fi
29         phase++;
30         csum_length = SUM_LENGTH;
31         max_size = min_size = ignore_existing = ignore_non_existing = 0;
32 -       update_only = always_checksum = size_only = 0;
33 +       downdate_only = update_only = always_checksum = size_only = 0;
34         ignore_times = 1;
35         if (append_mode)  /* resend w/o append mode */
36                 append_mode = -1; /* ... but only longer files */
37 --- old/options.c
38 +++ new/options.c
39 @@ -56,6 +56,7 @@ int preserve_gid = 0;
40  int preserve_times = 0;
41  int omit_dir_times = 0;
42  int update_only = 0;
43 +int downdate_only = 0;
44  int cvs_exclude = 0;
45  int dry_run = 0;
46  int do_xfers = 1;
47 @@ -291,6 +292,7 @@ void usage(enum logcode F)
48    rprintf(F,"     --backup-dir=DIR        make backups into hierarchy based in DIR\n");
49    rprintf(F,"     --suffix=SUFFIX         set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
50    rprintf(F," -u, --update                skip files that are newer on the receiver\n");
51 +  rprintf(F," -w, --downdate              skip files that are older on the receiver\n");
52    rprintf(F,"     --inplace               update destination files in-place (SEE MAN PAGE)\n");
53    rprintf(F,"     --append                append data onto shorter files\n");
54    rprintf(F," -d, --dirs                  transfer directories without recursing\n");
55 @@ -461,6 +463,7 @@ static struct poptOption long_options[] 
56    {"size-only",        0,  POPT_ARG_NONE,   &size_only, 0, 0, 0 },
57    {"one-file-system", 'x', POPT_ARG_NONE,   0, 'x', 0, 0 },
58    {"update",          'u', POPT_ARG_NONE,   &update_only, 0, 0, 0 },
59 +  {"downdate",        'w', POPT_ARG_NONE,   &downdate_only, 0, 0, 0 },
60    {"existing",         0,  POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
61    {"ignore-non-existing",0,POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
62    {"ignore-existing",  0,  POPT_ARG_NONE,   &ignore_existing, 0, 0, 0 },