From c4750c2a07772259375b530d8c8d74a86e92d198 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 17 Feb 2007 17:00:40 +0000 Subject: [PATCH] Make sure that a newly-created destination directory gets the same rules applied to it as other newly-created directories when --perms wasn't specified. --- generator.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/generator.c b/generator.c index e8a02657..f0a752bd 100644 --- a/generator.c +++ b/generator.c @@ -1143,14 +1143,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, return; } - /* If we're not preserving permissions, change the file-list's - * mode based on the local permissions and some heuristics. */ - if (!preserve_perms) { - int exists = statret == 0 - && S_ISDIR(st.st_mode) == S_ISDIR(file->mode); - file->mode = dest_mode(file->mode, st.st_mode, exists); - } - if (S_ISDIR(file->mode)) { /* The file to be received is a directory, so we need * to prepare appropriately. If there is already a @@ -1173,6 +1165,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, statret = -1; new_root_dir = 0; } + if (!preserve_perms) { /* See comment in non-dir code below. */ + file->mode = dest_mode(file->mode, st.st_mode, + statret == 0); + } if (statret != 0 && basis_dir[0] != NULL) { int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st, itemizing, code); @@ -1218,6 +1214,13 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, return; } + /* If we're not preserving permissions, change the file-list's + * mode based on the local permissions and some heuristics. */ + if (!preserve_perms) { + int exists = statret == 0 && !S_ISDIR(st.st_mode); + file->mode = dest_mode(file->mode, st.st_mode, exists); + } + #ifdef SUPPORT_HARD_LINKS if (preserve_hard_links && F_HLINK_NOT_FIRST(file) && hard_link_check(file, ndx, fname, statret, &st, itemizing, code)) -- 2.34.1