char fnamecmpbuf[MAXPATHLEN];
extern char *compare_dest;
extern int list_only;
+ extern int preserve_perms;
if (list_only) return;
statret = link_stat(fname,&st);
+ if (statret == 0 &&
+ !preserve_perms &&
+ (S_ISDIR(st.st_mode) == S_ISDIR(file->mode))) {
+ /* if the file exists already and we aren't perserving
+ presmissions then act as though the remote end sent
+ us the file permissions we already have */
+ file->mode = (file->mode & _S_IFMT) | (st.st_mode & ~_S_IFMT);
+ }
+
if (S_ISDIR(file->mode)) {
if (dry_run) return;
if (statret == 0 && !S_ISDIR(st.st_mode)) {