X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/a255c592e8fa9e4570ebbf333e95a402f9e84a03..17b5b32f75d4d00e00ff2664ca905c797f455bb1:/generator.c diff --git a/generator.c b/generator.c index c3ba30ce..5d051580 100644 --- a/generator.c +++ b/generator.c @@ -47,7 +47,7 @@ extern int protocol_version; extern int always_checksum; extern char *partial_dir; extern char *basis_dir[]; -extern int copy_dest; +extern int compare_dest; extern int link_dest; extern int whole_file; extern int local_server; @@ -146,17 +146,20 @@ static void sum_sizes_sqroot(struct sum_struct *sum, uint64 len) else { int32 c; uint64 l; - for (c = 1, l = len; l >>= 2; c <<= 1) { - assert(c > 0); + 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; + else { + blength = 0; + do { + blength |= c; + if (len < (uint64)blength * blength) + blength &= ~c; + c >>= 1; + } while (c >= 8); /* round to multiple of 8 */ + blength = MAX(blength, BLOCK_SIZE); } - blength = 0; - do { - blength |= c; - if (len < (uint64)blength * blength) - blength &= ~c; - c >>= 1; - } while (c >= 8); /* round to multiple of 8 */ - blength = MAX(blength, BLOCK_SIZE); } if (protocol_version < 27) { @@ -467,13 +470,13 @@ static void recv_generator(char *fname, struct file_struct *file, int i, safe_fname(fname)); } fnamecmp = fnamecmpbuf; - fnamecmp_type = FNAMECMP_BASIS_DIR + i; + fnamecmp_type = i; } } else #endif { fnamecmp = fnamecmpbuf; - fnamecmp_type = FNAMECMP_BASIS_DIR + i; + fnamecmp_type = i; } } } @@ -485,7 +488,7 @@ static void recv_generator(char *fname, struct file_struct *file, int i, stat_errno = ENOENT; } - if (partial_dir && (partialptr = partial_dir_fname(fname)) + if (partial_dir && (partialptr = partial_dir_fname(fname)) != NULL && link_stat(partialptr, &partial_st, 0) == 0 && S_ISREG(partial_st.st_mode)) { if (statret == -1) @@ -519,7 +522,7 @@ static void recv_generator(char *fname, struct file_struct *file, int i, return; } - if ((link_dest || copy_dest) && fnamecmp_type != FNAMECMP_FNAME) + if (!compare_dest && fnamecmp_type <= FNAMECMP_BASIS_DIR_HIGH) ; else if (unchanged_file(fnamecmp, file, &st)) { if (fnamecmp_type == FNAMECMP_FNAME) @@ -528,6 +531,13 @@ static void recv_generator(char *fname, struct file_struct *file, int i, } prepare_to_open: + if (partialptr) { + st = partial_st; + fnamecmp = partialptr; + fnamecmp_type = FNAMECMP_PARTIAL_DIR; + statret = 0; + } + if (dry_run || whole_file > 0) { statret = -1; goto notify_others; @@ -535,12 +545,6 @@ prepare_to_open: if (read_batch) goto notify_others; - if (partialptr) { - st = partial_st; - fnamecmp = partialptr; - fnamecmp_type = FNAMECMP_PARTIAL_DIR; - } - /* open the file */ fd = do_open(fnamecmp, O_RDONLY, 0); @@ -592,6 +596,8 @@ prepare_to_open: notify_others: write_int(f_out, i); + if (protocol_version >= 29 && inplace && !read_batch) + write_byte(f_out, fnamecmp_type); if (f_out_name >= 0) write_byte(f_out_name, fnamecmp_type); @@ -685,6 +691,9 @@ void generate_files(int f_out, struct file_list *flist, char *local_name, write_int(f_out, -1); + /* Read post-redo-phase MSG_DONE and any prior messages. */ + get_redo_num(); + if (preserve_hard_links) do_hard_links();