e5a5ce5cd3bf322ec7414f9c79cdd8ab89ddbda9
[rsync/rsync-patches.git] / max-size.diff
1 --- orig/generator.c    2004-09-20 19:50:13
2 +++ generator.c 2004-07-03 20:20:46
3 @@ -41,6 +41,7 @@ extern int make_backups;
4  extern int csum_length;
5  extern int ignore_times;
6  extern int size_only;
7 +extern OFF_T max_size;
8  extern int io_timeout;
9  extern int protocol_version;
10  extern int always_checksum;
11 @@ -339,6 +340,10 @@ static void recv_generator(char *fname, 
12                     && verbose && f_out != -1)
13                         rprintf(FINFO, "%s/\n", safe_fname(fname));
14                 return;
15 +       } else if (max_size && file->length > max_size) {
16 +               if (verbose > 1)
17 +                       rprintf(FINFO, "%s is over max-size\n", fname);
18 +               return;
19         }
20  
21         if (preserve_links && S_ISLNK(file->mode)) {
22 --- orig/options.c      2004-09-23 17:42:07
23 +++ options.c   2004-08-13 18:26:04
24 @@ -90,6 +90,7 @@ int delete_after = 0;
25  int only_existing = 0;
26  int opt_ignore_existing = 0;
27  int max_delete = 0;
28 +OFF_T max_size = 0;
29  int ignore_errors = 0;
30  int modify_window = 0;
31  int blocking_io = -1;
32 @@ -140,6 +141,7 @@ char *batch_name = NULL;
33  
34  static int daemon_opt;   /* sets am_daemon after option error-reporting */
35  static int modify_window_set;
36 +static char *max_size_arg;
37  
38  /** Local address to bind.  As a character string because it's
39   * interpreted by the IPv6 layer: should be a numeric IP4 or IP6
40 @@ -268,6 +270,7 @@ void usage(enum logcode F)
41    rprintf(F,"     --delete-after          receiver deletes after transferring, not before\n");
42    rprintf(F,"     --ignore-errors         delete even if there are I/O errors\n");
43    rprintf(F,"     --max-delete=NUM        don't delete more than NUM files\n");
44 +  rprintf(F,"     --max-size=SIZE         don't transfer any file larger than SIZE\n");
45    rprintf(F,"     --partial               keep partially transferred files\n");
46    rprintf(F,"     --partial-dir=DIR       put a partially transferred file into DIR\n");
47    rprintf(F,"     --force                 force deletion of directories even if not empty\n");
48 @@ -319,7 +322,7 @@ void usage(enum logcode F)
49  enum {OPT_VERSION = 1000, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
50        OPT_DELETE_AFTER, OPT_DELETE_EXCLUDED, OPT_LINK_DEST,
51        OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
52 -      OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT,
53 +      OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_TIMEOUT, OPT_MAX_SIZE,
54        OPT_REFUSED_BASE = 9000};
55  
56  static struct poptOption long_options[] = {
57 @@ -374,6 +377,7 @@ static struct poptOption long_options[] 
58    {"rsh",             'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
59    {"block-size",      'B', POPT_ARG_INT,    &block_size, 0, 0, 0 },
60    {"max-delete",       0,  POPT_ARG_INT,    &max_delete, 0, 0, 0 },
61 +  {"max-size",         0,  POPT_ARG_STRING, &max_size_arg,  OPT_MAX_SIZE, 0, 0 },
62    {"timeout",          0,  POPT_ARG_INT,    &io_timeout, OPT_TIMEOUT, 0, 0 },
63    {"temp-dir",        'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
64    {"compare-dest",     0,  POPT_ARG_STRING, &compare_dest, 0, 0, 0 },
65 @@ -600,6 +604,33 @@ int parse_arguments(int *argc, const cha
66                         read_batch = 1;
67                         break;
68  
69 +               case OPT_MAX_SIZE:
70 +                       for (arg = max_size_arg; isdigit(*arg); arg++) {}
71 +                       if (*arg == '.')
72 +                               for (arg++; isdigit(*arg); arg++) {}
73 +                       if (arg == max_size_arg)
74 +                               arg = "?";
75 +                       switch (*arg) {
76 +                       case 'k': case 'K':
77 +                               max_size = atof(max_size_arg) * 1024;
78 +                               break;
79 +                       case 'm': case 'M':
80 +                               max_size = atof(max_size_arg) * 1024*1024;
81 +                               break;
82 +                       case 'g': case 'G':
83 +                               max_size = atof(max_size_arg) * 1024*1024*1024;
84 +                               break;
85 +                       case '\0':
86 +                               break;
87 +                       default:
88 +                               rprintf(FERROR,
89 +                                       "--max-size value is invalid: %s\n",
90 +                                       max_size_arg);
91 +                               exit_cleanup(RERR_SYNTAX);
92 +                               break;
93 +                       }
94 +                       break;
95 +
96                 case OPT_TIMEOUT:
97                         if (io_timeout && io_timeout < select_timeout)
98                                 select_timeout = io_timeout;
99 @@ -993,6 +1024,11 @@ void server_options(char **args,int *arg
100                 args[ac++] = arg;
101         }
102  
103 +       if (max_size && am_sender) {
104 +               args[ac++] = "--max-size";
105 +               args[ac++] = max_size_arg;
106 +       }
107 +
108         if (io_timeout) {
109                 if (asprintf(&arg, "--timeout=%d", io_timeout) < 0)
110                         goto oom;
111 --- orig/rsync.yo       2004-09-24 16:42:30
112 +++ rsync.yo    2004-07-03 20:20:46
113 @@ -345,6 +345,7 @@ verb(
114       --delete-after          receiver deletes after transfer, not before
115       --ignore-errors         delete even if there are I/O errors
116       --max-delete=NUM        don't delete more than NUM files
117 +     --max-size=SIZE         don't transfer any file larger than SIZE
118       --partial               keep partially transferred files
119       --partial-dir=DIR       put a partially transferred file into DIR
120       --force                 force deletion of dirs even if not empty
121 @@ -635,6 +636,11 @@ dit(bf(--max-delete=NUM)) This tells rsy
122  files or directories. This is useful when mirroring very large trees
123  to prevent disasters.
124  
125 +dit(bf(--max-size=SIZE)) This tells rsync to avoid transferring any
126 +file that is larger than the specified SIZE. The SIZE value can be
127 +suffixed with a letter to indicate a size multiplier (K, M, or G) and
128 +may be a fractional value (e.g. "--max-size=1.5m").
129 +
130  dit(bf(--delete)) This tells rsync to delete any files on the receiving
131  side that aren't on the sending side.   Files that are excluded from
132  transfer are excluded from being deleted unless you use --delete-excluded.