Unified · Split
| @@ -177,6 +177,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) · 176 unmodified lines | ||
| 177 | 177 | char fnamecmpbuf[MAXPATHLEN]; |
| 178 | 178 | extern char *compare_dest; |
| 179 | 179 | extern int list_only; |
| 180 | + extern int preserve_perms; | |
| 180 | 181 | |
| 181 | 182 | if (list_only) return; |
| 182 | 183 | |
| @@ -185,6 +186,15 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) · 2 unmodified lines | ||
| 185 | 186 | |
| 186 | 187 | statret = link_stat(fname,&st); |
| 187 | 188 | |
| 189 | + if (statret == 0 && | |
| 190 | + !preserve_perms && | |
| 191 | + (S_ISDIR(st.st_mode) == S_ISDIR(file->mode))) { | |
| 192 | + /* if the file exists already and we aren't perserving | |
| 193 | + presmissions then act as though the remote end sent | |
| 194 | + us the file permissions we already have */ | |
| 195 | + file->mode = st.st_mode; | |
| 196 | + } | |
| 197 | + | |
| 188 | 198 | if (S_ISDIR(file->mode)) { |
| 189 | 199 | if (dry_run) return; |
| 190 | 200 | if (statret == 0 && !S_ISDIR(st.st_mode)) { |
| @@ -303,6 +303,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen) · 302 unmodified lines | ||
| 303 | 303 | int phase=0; |
| 304 | 304 | int recv_ok; |
| 305 | 305 | extern struct stats stats; |
| 306 | + extern int preserve_perms; | |
| 306 | 307 | struct stats initial_stats; |
| 307 | 308 | |
| 308 | 309 | if (verbose > 2) { |
| @@ -383,6 +384,13 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen) · 74 unmodified lines | ||
| 383 | 384 | continue; |
| 384 | 385 | } |
| 385 | 386 | |
| 387 | + if (fd1 != -1 && !preserve_perms) { | |
| 388 | + /* if the file exists already and we aren't perserving | |
| 389 | + presmissions then act as though the remote end sent | |
| 390 | + us the file permissions we already have */ | |
| 391 | + file->mode = st.st_mode; | |
| 392 | + } | |
| 393 | + | |
| 386 | 394 | if (fd1 != -1 && st.st_size > 0) { |
| 387 | 395 | buf = map_file(fd1,st.st_size); |
| 388 | 396 | if (verbose > 2) |