-@@ -1178,7 +1187,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, FILEFLAGS(sx.st.st_flags), "directory", del_opts) != 0)
- return;
- statret = -1;
- }
-@@ -1291,7 +1300,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, FILEFLAGS(sx.st.st_flags), "symlink", del_opts) != 0)
- goto cleanup;
- } else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
-@@ -1368,7 +1377,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, FILEFLAGS(sx.st.st_flags), t, del_opts) != 0)
- goto cleanup;
- } else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
-@@ -1457,7 +1466,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, FILEFLAGS(sx.st.st_flags), "regular file", del_opts) != 0)
- goto cleanup;
- statret = -1;
- stat_errno = ENOENT;
---- old/options.c
-+++ new/options.c
-@@ -48,6 +48,7 @@ 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 (S_ISDIR(file->mode)) {
+ 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;