| 1 | --- orig/generator.c 2004-07-29 16:08:03 |
| 2 | +++ generator.c 2004-07-03 20:20:46 |
| 3 | @@ -39,6 +39,7 @@ extern int opt_ignore_existing; |
| 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 | @@ -337,6 +338,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-07-29 16:08:03 |
| 23 | +++ options.c 2004-07-15 02:34:44 |
| 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 | @@ -589,6 +593,32 @@ 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.\n"); |
| 90 | + exit_cleanup(RERR_SYNTAX); |
| 91 | + break; |
| 92 | + } |
| 93 | + break; |
| 94 | + |
| 95 | case OPT_TIMEOUT: |
| 96 | if (io_timeout && io_timeout < select_timeout) |
| 97 | select_timeout = io_timeout; |
| 98 | @@ -938,6 +968,11 @@ void server_options(char **args,int *arg |
| 99 | args[ac++] = arg; |
| 100 | } |
| 101 | |
| 102 | + if (max_size && am_sender) { |
| 103 | + args[ac++] = "--max-size"; |
| 104 | + args[ac++] = max_size_arg; |
| 105 | + } |
| 106 | + |
| 107 | if (io_timeout) { |
| 108 | if (asprintf(&arg, "--timeout=%d", io_timeout) < 0) |
| 109 | goto oom; |
| 110 | --- orig/rsync.yo 2004-07-29 16:08:04 |
| 111 | +++ rsync.yo 2004-07-03 20:20:46 |
| 112 | @@ -316,6 +316,7 @@ verb( |
| 113 | --delete-after receiver deletes after transfer, not before |
| 114 | --ignore-errors delete even if there are I/O errors |
| 115 | --max-delete=NUM don't delete more than NUM files |
| 116 | + --max-size=SIZE don't transfer any file larger than SIZE |
| 117 | --partial keep partially transferred files |
| 118 | --partial-dir=DIR put a partially transferred file into DIR |
| 119 | --force force deletion of dirs even if not empty |
| 120 | @@ -593,6 +594,11 @@ dit(bf(--max-delete=NUM)) This tells rsy |
| 121 | files or directories. This is useful when mirroring very large trees |
| 122 | to prevent disasters. |
| 123 | |
| 124 | +dit(bf(--max-size=SIZE)) This tells rsync to avoid transferring any |
| 125 | +file that is larger than the specified SIZE. The SIZE value can be |
| 126 | +suffixed with a letter to indicate a size multiplier (K, M, or G) and |
| 127 | +may be a fractional value (e.g. "--max-size=1.5m"). |
| 128 | + |
| 129 | dit(bf(--delete)) This tells rsync to delete any files on the receiving |
| 130 | side that aren't on the sending side. Files that are excluded from |
| 131 | transfer are excluded from being deleted unless you use --delete-excluded. |