-@@ -1177,7 +1186,7 @@ static void recv_generator(char *fname,
- * we need to delete it. If it doesn't exist, then
- * (perhaps recursively) create it. */
- if (statret == 0 && !S_ISDIR(st.st_mode)) {
-- if (delete_item(fname, st.st_mode, "directory", del_opts) != 0)
-+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), "directory", del_opts) != 0)
- return;
- statret = -1;
- }
-@@ -1275,7 +1284,7 @@ static void recv_generator(char *fname,
- }
- /* Not the right symlink (or not a symlink), so
- * delete it. */
-- if (delete_item(fname, st.st_mode, "symlink", del_opts) != 0)
-+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), "symlink", del_opts) != 0)
- return;
- } else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
-@@ -1354,7 +1363,7 @@ static void recv_generator(char *fname,
- goto return_with_success;
- return;
- }
-- if (delete_item(fname, st.st_mode, t, del_opts) != 0)
-+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), t, del_opts) != 0)
- return;
- } else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
-@@ -1445,7 +1454,7 @@ static void recv_generator(char *fname,
- fnamecmp_type = FNAMECMP_FNAME;
-
- if (statret == 0 && !S_ISREG(st.st_mode)) {
-- if (delete_item(fname, st.st_mode, "regular file", del_opts) != 0)
-+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), "regular file", del_opts) != 0)
- return;
- statret = -1;
- stat_errno = ENOENT;
---- old/options.c
-+++ new/options.c
-@@ -48,6 +48,7 @@ int copy_links = 0;
- int preserve_links = 0;
- int preserve_hard_links = 0;
+ if (statret == 0 && sx.st.st_uid == our_uid)
+ del_opts |= DEL_OWNED_BY_US;
++#ifdef SUPPORT_FLAGS
++ if (statret == 0 && fileflags_ndx && sx.st.st_flags & NODELETE_FLAGS)
++ del_opts |= DEL_AN_IMMUTABLE;
++#endif
+
+ if (is_dir) {
+ if (!implied_dirs && file->flags & FLAG_IMPLIED_DIR)
+diff --git a/options.c b/options.c
+--- a/options.c
++++ b/options.c
+@@ -52,6 +52,7 @@ int preserve_hard_links = 0;
+ int preserve_acls = 0;
+ int preserve_xattrs = 0;