X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/943882a289da2ad2d6ae1ef9c8bba494d769ba50..fe8c0a9824bf990ae3ff692d25105dd2c9f0ebf4:/rsync.c diff --git a/rsync.c b/rsync.c index 2f772ace..b61128b1 100644 --- a/rsync.c +++ b/rsync.c @@ -74,6 +74,7 @@ static int delete_file(char *fname) extern int force_delete; STRUCT_STAT st; int ret; + extern int recurse; if (do_unlink(fname) == 0 || errno == ENOENT) return 0; @@ -93,7 +94,8 @@ static int delete_file(char *fname) } if (do_rmdir(fname) == 0 || errno == ENOENT) return 0; - if (!force_delete || (errno != ENOTEMPTY && errno != EEXIST)) { + if (!force_delete || !recurse || + (errno != ENOTEMPTY && errno != EEXIST)) { rprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno)); return -1; } @@ -147,7 +149,6 @@ static void send_sums(struct sum_struct *s,int f_out) write_int(f_out,s->sums[i].sum1); write_buf(f_out,s->sums[i].sum2,csum_length); } - write_flush(f_out); } @@ -528,7 +529,6 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) write_int(f_out,i); send_sums(s,f_out); - write_flush(f_out); close(fd); if (buf) unmap_file(buf); @@ -638,11 +638,7 @@ static void add_delete_entry(struct file_struct *file) { if (dlist_len == dlist_alloc_len) { dlist_alloc_len += 1024; - if (!delete_list) { - delete_list = (struct delete_list *)malloc(sizeof(delete_list[0])*dlist_alloc_len); - } else { - delete_list = (struct delete_list *)realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len); - } + delete_list = (struct delete_list *)Realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len); if (!delete_list) out_of_memory("add_delete_entry"); } @@ -696,7 +692,8 @@ static void delete_files(struct file_list *flist) if (!S_ISDIR(flist->files[j]->mode) || !(flist->files[j]->flags & FLAG_DELETE)) continue; - if (delete_already_done(flist, j)) continue; + if (remote_version < 19 && + delete_already_done(flist, j)) continue; name = strdup(f_name(flist->files[j])); @@ -710,7 +707,8 @@ static void delete_files(struct file_list *flist) for (i=local_file_list->count-1;i>=0;i--) { if (!local_file_list->files[i]->basename) continue; - if (S_ISDIR(local_file_list->files[i]->mode)) + if (remote_version < 19 && + S_ISDIR(local_file_list->files[i]->mode)) add_delete_entry(local_file_list->files[i]); if (-1 == flist_find(flist,local_file_list->files[i])) { delete_one(local_file_list->files[i]); @@ -771,7 +769,6 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen) if (verbose > 2) rprintf(FINFO,"recv_files phase=%d\n",phase); write_int(f_gen,-1); - write_flush(f_gen); continue; } break; @@ -970,7 +967,7 @@ void send_files(struct file_list *flist,int f_out,int f_in) if (verbose > 2) rprintf(FINFO,"send_files starting\n"); - setup_nonblocking(f_in,f_out); + setup_readbuffer(f_in); while (1) { i = read_int(f_in); @@ -979,7 +976,6 @@ void send_files(struct file_list *flist,int f_out,int f_in) phase++; csum_length = SUM_LENGTH; write_int(f_out,-1); - write_flush(f_out); if (verbose > 2) rprintf(FINFO,"send_files phase=%d\n",phase); continue; @@ -1061,7 +1057,6 @@ void send_files(struct file_list *flist,int f_out,int f_in) printf("%s\n",fname+offset); match_sums(f_out,s,buf,st.st_size); - write_flush(f_out); if (buf) unmap_file(buf); close(fd); @@ -1078,7 +1073,6 @@ void send_files(struct file_list *flist,int f_out,int f_in) match_report(); write_int(f_out,-1); - write_flush(f_out); } @@ -1118,7 +1112,6 @@ void generate_files(int f,struct file_list *flist,char *local_name,int f_recv) rprintf(FINFO,"generate_files phase=%d\n",phase); write_int(f,-1); - write_flush(f); /* we expect to just sit around now, so don't exit on a timeout. If we really get a timeout then the other process should exit */ @@ -1138,7 +1131,6 @@ void generate_files(int f,struct file_list *flist,char *local_name,int f_recv) rprintf(FINFO,"generate_files phase=%d\n",phase); write_int(f,-1); - write_flush(f); }