if (preserve_times && cmp_time(sxp->st.st_mtime, file->modtime) != 0)
return 0;
- if (preserve_perms && !BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS))
- return 0;
-
- if (preserve_executability && ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0)))
+ if (preserve_perms) {
+ if (!BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS))
+ return 0;
+ } else if (preserve_executability
+ && ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0)))
return 0;
if (am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file))
;
} else
#endif
- if ((preserve_perms || preserve_executability)
- && !BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS))
+ if (preserve_perms) {
+ if (!BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS))
+ iflags |= ITEM_REPORT_PERMS;
+ } else if (preserve_executability
+ && ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0)))
iflags |= ITEM_REPORT_PERMS;
if (uid_ndx && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid)
iflags |= ITEM_REPORT_OWNER;
fname = f_name(file, NULL);
if (!(file->mode & S_IWUSR))
do_chmod(fname, file->mode);
- if (need_retouch_dir_times)
- set_modtime(fname, file->modtime, file->mode);
+ if (need_retouch_dir_times) {
+ STRUCT_STAT st;
+ if (link_stat(fname, &st, 0) == 0
+ && cmp_time(st.st_mtime, file->modtime) != 0)
+ set_modtime(fname, file->modtime, file->mode);
+ }
if (allowed_lull && !(counter % lull_mod))
maybe_send_keepalive();
else if (!(counter & 0xFF))