Prepare repository for more development.
[rsync/rsync.git] / generator.c
index 1fcdb4c..724cebe 100644 (file)
@@ -763,11 +763,12 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len)
        else if (len <= BLOCK_SIZE * BLOCK_SIZE)
                blength = BLOCK_SIZE;
        else {
+               int32 max_blength = protocol_version < 30 ? OLD_MAX_BLOCK_SIZE : MAX_BLOCK_SIZE;
                int32 c;
                int cnt;
                for (c = 1, l = len, cnt = 0; l >>= 2; c <<= 1, cnt++) {}
-               if (cnt >= 31 || c >= MAX_BLOCK_SIZE)
-                       blength = MAX_BLOCK_SIZE;
+               if (c < 0 || c >= max_blength)
+                       blength = max_blength;
                else {
                    blength = 0;
                    do {
@@ -1952,9 +1953,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
        if (read_batch)
                goto cleanup;
 
-       if (statret != 0 || whole_file || sx.st.st_size <= 0)
+       if (statret != 0 || whole_file)
                write_sum_head(f_out, NULL);
-       else {
+       else if (sx.st.st_size <= 0) {
+               write_sum_head(f_out, NULL);
+               close(fd);
+       } else {
                if (generate_and_send_sums(fd, sx.st.st_size, f_out, f_copy) < 0) {
                        rprintf(FWARNING,
                            "WARNING: file is too large for checksum sending: %s\n",