Allow --max-size=0 and --min-size=0.
authorWayne Davison <wayned@samba.org>
Sat, 24 Dec 2011 20:33:17 +0000 (12:33 -0800)
committerWayne Davison <wayned@samba.org>
Sat, 24 Dec 2011 20:35:37 +0000 (12:35 -0800)
Fixes bug 7965.

generator.c
options.c
rsync.yo

index e05d889c257c5bbbae878ba9eccc2d8619839236..c44ba3bb08d3794842b7b4665f0c1c391b85a74e 100644 (file)
@@ -1602,7 +1602,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                goto cleanup;
        }
 
-       if (max_size > 0 && F_LENGTH(file) > max_size) {
+       if (max_size >= 0 && F_LENGTH(file) > max_size) {
                if (INFO_GTE(SKIP, 1)) {
                        if (solo_file)
                                fname = f_name(file, NULL);
@@ -1610,7 +1610,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                }
                goto cleanup;
        }
-       if (min_size > 0 && F_LENGTH(file) < min_size) {
+       if (min_size >= 0 && F_LENGTH(file) < min_size) {
                if (INFO_GTE(SKIP, 1)) {
                        if (solo_file)
                                fname = f_name(file, NULL);
@@ -2062,9 +2062,11 @@ void check_for_finished_files(int itemizing, enum logcode code, int check_redo)
 #endif
 
                if (check_redo && (ndx = get_redo_num()) != -1) {
+                       OFF_T save_max_size = max_size;
+                       OFF_T save_min_size = min_size;
                        csum_length = SUM_LENGTH;
-                       max_size = -max_size;
-                       min_size = -min_size;
+                       max_size = -1;
+                       min_size = -1;
                        ignore_existing = -ignore_existing;
                        ignore_non_existing = -ignore_non_existing;
                        update_only = -update_only;
@@ -2088,8 +2090,8 @@ void check_for_finished_files(int itemizing, enum logcode code, int check_redo)
                        cur_flist = flist;
 
                        csum_length = SHORT_SUM_LENGTH;
-                       max_size = -max_size;
-                       min_size = -min_size;
+                       max_size = save_max_size;
+                       min_size = save_min_size;
                        ignore_existing = -ignore_existing;
                        ignore_non_existing = -ignore_non_existing;
                        update_only = -update_only;
index 2e1c1880f49c1aa2674bffc82a03bc9cc3f5697b..9b701d36a7efa03beb2251ef34703c370c25943c 100644 (file)
--- a/options.c
+++ b/options.c
@@ -114,8 +114,8 @@ int ignore_existing = 0;
 int ignore_non_existing = 0;
 int need_messages_from_generator = 0;
 int max_delete = INT_MIN;
-OFF_T max_size = 0;
-OFF_T min_size = 0;
+OFF_T max_size = -1;
+OFF_T min_size = -1;
 int ignore_errors = 0;
 int modify_window = 0;
 int blocking_io = -1;
@@ -1590,7 +1590,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        break;
 
                case OPT_MAX_SIZE:
-                       if ((max_size = parse_size_arg(&max_size_arg, 'b')) <= 0) {
+                       if ((max_size = parse_size_arg(&max_size_arg, 'b')) < 0) {
                                snprintf(err_buf, sizeof err_buf,
                                        "--max-size value is invalid: %s\n",
                                        max_size_arg);
@@ -1599,7 +1599,7 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        break;
 
                case OPT_MIN_SIZE:
-                       if ((min_size = parse_size_arg(&min_size_arg, 'b')) <= 0) {
+                       if ((min_size = parse_size_arg(&min_size_arg, 'b')) < 0) {
                                snprintf(err_buf, sizeof err_buf,
                                        "--min-size value is invalid: %s\n",
                                        min_size_arg);
@@ -2545,11 +2545,11 @@ void server_options(char **args, int *argc_p)
                        args[ac++] = arg;
                } else if (max_delete == 0)
                        args[ac++] = "--max-delete=-1";
-               if (min_size) {
+               if (min_size >= 0) {
                        args[ac++] = "--min-size";
                        args[ac++] = min_size_arg;
                }
-               if (max_size) {
+               if (max_size >= 0) {
                        args[ac++] = "--max-size";
                        args[ac++] = max_size_arg;
                }
index 14b2536745d8f0c4ceaf8cf16b9684b1a7d81ef7..e18fd2c2551f175ab91d090e0975a87d9416fefd 100644 (file)
--- a/rsync.yo
+++ b/rsync.yo
@@ -1448,11 +1448,15 @@ be offset by one byte in the indicated direction.
 Examples: --max-size=1.5mb-1 is 1499999 bytes, and --max-size=2g+1 is
 2147483649 bytes.
 
+Note that rsync versions prior to 3.1.0 did not allow bf(--max-size=0).
+
 dit(bf(--min-size=SIZE)) This tells rsync to avoid transferring any
 file that is smaller than the specified SIZE, which can help in not
 transferring small, junk files.
 See the bf(--max-size) option for a description of SIZE and other information.
 
+Note that rsync versions prior to 3.1.0 did not allow bf(--min-size=0).
+
 dit(bf(-B, --block-size=BLOCKSIZE)) This forces the block size used in
 rsync's delta-transfer algorithm to a fixed value.  It is normally selected based on
 the size of each file being updated.  See the technical report for details.