-@@ -1211,7 +1222,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(sx.st.st_mode)) {
-- if (delete_item(fname, sx.st.st_mode, "directory", del_opts) != 0)
-+ if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), "directory", del_opts) != 0)
- return;
- statret = -1;
- }
-@@ -1324,7 +1335,7 @@ static void recv_generator(char *fname,
- }
- /* Not the right symlink (or not a symlink), so
- * delete it. */
-- if (delete_item(fname, sx.st.st_mode, "symlink", del_opts) != 0)
-+ if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), "symlink", del_opts) != 0)
- goto cleanup;
- } else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
-@@ -1401,7 +1412,7 @@ static void recv_generator(char *fname,
- goto return_with_success;
- goto cleanup;
- }
-- if (delete_item(fname, sx.st.st_mode, t, del_opts) != 0)
-+ if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), t, del_opts) != 0)
- goto cleanup;
- } else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
-@@ -1490,7 +1501,7 @@ static void recv_generator(char *fname,
- fnamecmp_type = FNAMECMP_FNAME;
-
- if (statret == 0 && !S_ISREG(sx.st.st_mode)) {
-- if (delete_item(fname, sx.st.st_mode, "regular file", del_opts) != 0)
-+ if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), "regular file", del_opts) != 0)
- goto cleanup;
- statret = -1;
- stat_errno = ENOENT;
---- old/options.c
-+++ new/options.c
-@@ -49,6 +49,7 @@ 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;