Another minor update for the changes in options.c.
[rsync/rsync-patches.git] / min-size.diff
1 --- orig/generator.c    2005-09-29 18:03:00
2 +++ generator.c 2005-10-14 19:50:15
3 @@ -61,6 +61,7 @@ extern int csum_length;
4  extern int ignore_times;
5  extern int size_only;
6  extern OFF_T max_size;
7 +extern OFF_T min_size;
8  extern int io_error;
9  extern int allowed_lull;
10  extern int sock_f_out;
11 @@ -872,6 +873,15 @@ static void recv_generator(char *fname, 
12                 }
13                 return;
14         }
15 +       if (min_size && file->length < min_size) {
16 +               if (verbose > 1) {
17 +                       if (the_file_list->count == 1)
18 +                               fname = f_name(file);
19 +                       rprintf(FINFO, "%s is under min-size\n",
20 +                               safe_fname(fname));
21 +               }
22 +               return;
23 +       }
24  
25         if (ignore_existing && statret == 0) {
26                 if (verbose > 1)
27 @@ -1265,7 +1275,7 @@ void generate_files(int f_out, struct fi
28  
29         phase++;
30         csum_length = SUM_LENGTH;
31 -       max_size = ignore_existing = ignore_non_existing = 0;
32 +       max_size = min_size = ignore_existing = ignore_non_existing = 0;
33         update_only = always_checksum = size_only = 0;
34         ignore_times = 1;
35         if (append_mode)  /* resend w/o append mode */
36 --- orig/options.c      2005-10-14 19:47:07
37 +++ options.c   2005-10-14 19:08:38
38 @@ -99,6 +99,7 @@ int ignore_non_existing = 0;
39  int need_messages_from_generator = 0;
40  int max_delete = 0;
41  OFF_T max_size = 0;
42 +OFF_T min_size = 0;
43  int ignore_errors = 0;
44  int modify_window = 0;
45  int blocking_io = -1;
46 @@ -167,7 +168,7 @@ static int itemize_changes = 0;
47  static int refused_delete, refused_archive_part;
48  static int refused_partial, refused_progress, refused_delete_before;
49  static int refused_inplace;
50 -static char *max_size_arg;
51 +static char *max_size_arg, *min_size_arg;
52  static char partialdir_for_delayupdate[] = ".~tmp~";
53  
54  /** Local address to bind.  As a character string because it's
55 @@ -308,6 +309,7 @@ void usage(enum logcode F)
56    rprintf(F,"     --force                 force deletion of directories even if not empty\n");
57    rprintf(F,"     --max-delete=NUM        don't delete more than NUM files\n");
58    rprintf(F,"     --max-size=SIZE         don't transfer any file larger than SIZE\n");
59 +  rprintf(F,"     --min-size=SIZE         don't transfer any file smaller than SIZE\n");
60    rprintf(F,"     --partial               keep partially transferred files\n");
61    rprintf(F,"     --partial-dir=DIR       put a partially transferred file into DIR\n");
62    rprintf(F,"     --delay-updates         put all updated files into place at transfer's end\n");
63 @@ -361,7 +363,7 @@ void usage(enum logcode F)
64  
65  enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
66        OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
67 -      OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
68 +      OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE,
69        OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
70        OPT_REFUSED_BASE = 9000};
71  
72 @@ -419,6 +421,7 @@ static struct poptOption long_options[] 
73    {"ignore-existing",  0,  POPT_ARG_NONE,   &ignore_existing, 0, 0, 0 },
74    {"ignore-non-existing",0,POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
75    {"max-size",         0,  POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
76 +  {"min-size",         0,  POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
77    {"sparse",          'S', POPT_ARG_NONE,   &sparse_files, 0, 0, 0 },
78    {"inplace",          0,  POPT_ARG_NONE,   &inplace, 0, 0, 0 },
79    {"append",           0,  POPT_ARG_VAL,    &append_mode, 1, 0, 0 },
80 @@ -923,6 +926,15 @@ int parse_arguments(int *argc, const cha
81                         }
82                         break;
83  
84 +               case OPT_MIN_SIZE:
85 +                       if ((min_size = parse_size_arg(&min_size_arg, 'b')) <= 0) {
86 +                               snprintf(err_buf, sizeof err_buf,
87 +                                       "--min-size value is invalid: %s\n",
88 +                                       min_size_arg);
89 +                               return 0;
90 +                       }
91 +                       break;
92 +
93                 case OPT_LINK_DEST:
94  #ifdef HAVE_LINK
95                         link_dest = 1;
96 @@ -1443,6 +1455,11 @@ void server_options(char **args,int *arg
97                 args[ac++] = arg;
98         }
99  
100 +       if (min_size && am_sender) {
101 +               args[ac++] = "--min-size";
102 +               args[ac++] = min_size_arg;
103 +       }
104 +
105         if (max_size && am_sender) {
106                 args[ac++] = "--max-size";
107                 args[ac++] = max_size_arg;
108 --- orig/rsync.yo       2005-10-14 18:58:31
109 +++ rsync.yo    2005-10-14 19:09:25
110 @@ -341,6 +341,7 @@ to the detailed description below for a 
111       --force                 force deletion of dirs even if not empty
112       --max-delete=NUM        don't delete more than NUM files
113       --max-size=SIZE         don't transfer any file larger than SIZE
114 +     --min-size=SIZE         don't transfer any file smaller than SIZE
115       --partial               keep partially transferred files
116       --partial-dir=DIR       put a partially transferred file into DIR
117       --delay-updates         put all updated files into place at end
118 @@ -812,6 +813,11 @@ be offset by one byte in the indicated d
119  Examples: --max-size=1.5mt-1 is 1499999 bytes, and --max-size=2g+1 is
120  2147483649 bytes.
121  
122 +dit(bf(--min-size=SIZE)) This tells rsync to avoid transferring any
123 +file that is smaller than the specified SIZE, which can help in not
124 +transferring small, junk files.
125 +See the bf(--max-size) option for a description of SIZE.
126 +
127  dit(bf(-B, --block-size=BLOCKSIZE)) This forces the block size used in
128  the rsync algorithm to a fixed value.  It is normally selected based on
129  the size of each file being updated.  See the technical report for details.