Added logic to the receiving side to ensure that the --delete-during
[rsync/rsync.git] / rsync.c
diff --git a/rsync.c b/rsync.c
index 734a373..21f5288 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -45,8 +45,11 @@ extern int gid_ndx;
 extern int inc_recurse;
 extern int inplace;
 extern int flist_eof;
+extern int msgs2stderr;
 extern int keep_dirlinks;
 extern int make_backups;
+extern int delete_during;
+extern int check_for_io_err;
 extern struct file_list *cur_flist, *first_flist, *dir_flist;
 extern struct chmod_mode_struct *daemon_chmod_modes;
 #ifdef ICONV_OPTION
@@ -79,23 +82,23 @@ void setup_iconv(void)
 # endif
 
        if (!am_server && !allow_8bit_chars) {
-
                /* It's OK if this fails... */
                ic_chck = iconv_open(defset, defset);
 
-               if (DEBUG_GTE(ICONV, 1)) {
+               if (DEBUG_GTE(ICONV, 2)) {
                        if (ic_chck == (iconv_t)-1) {
                                rprintf(FINFO,
-                                       "note: iconv_open(\"%s\", \"%s\") failed (%d)"
-                                       " -- using isprint() instead of iconv().\n",
+                                       "msg checking via isprint()"
+                                       " (iconv_open(\"%s\", \"%s\") errno: %d)\n",
                                        defset, defset, errno);
                        } else {
                                rprintf(FINFO,
-                                       "note: iconv_open(\"%s\", \"%s\") succeeded.\n",
-                                       defset, defset);
+                                       "msg checking charset: %s\n",
+                                       defset);
                        }
                }
-       }
+       } else
+               ic_chck = (iconv_t)-1;
 
 # ifdef ICONV_OPTION
        if (!iconv_opt)
@@ -125,10 +128,9 @@ void setup_iconv(void)
                exit_cleanup(RERR_UNSUPPORTED);
        }
 
-       if (INFO_GTE(MISC, 2)) {
-               rprintf(FINFO, "%s charset: %s\n",
-                       am_server ? "server" : "client",
-                       *charset ? charset : "[LOCALE]");
+       if (DEBUG_GTE(ICONV, 1)) {
+               rprintf(FINFO, "[%s] charset: %s\n",
+                       who_am_i(), *charset ? charset : "[LOCALE]");
        }
 # endif
 }
@@ -252,8 +254,15 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
        while (1) {
                ndx = read_ndx(f_in);
 
-               if (ndx >= 0)
+               if (ndx >= 0) {
+                       if (check_for_io_err) {
+                               /* Let generator know there was no I/O error. */
+                               send_msg_int(MSG_IO_ERROR, 0);
+                               check_for_io_err = 0;
+                       }
                        break;
+               }
+               check_for_io_err = 0;
                if (ndx == NDX_DONE)
                        return ndx;
                if (!inc_recurse || am_sender)
@@ -278,13 +287,19 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
                        rprintf(FINFO, "[%s] receiving flist for dir %d\n",
                                who_am_i(), ndx);
                }
-               negate_output_levels(); /* turn off all info/debug output */
+               if (!msgs2stderr)
+                       negate_output_levels(); /* turn off all info/debug output */
                send_msg_int(MSG_FLIST, ndx);
                start_flist_forward(f_in);
                flist = recv_file_list(f_in);
                flist->parent_ndx = ndx;
                stop_flist_forward();
-               negate_output_levels(); /* restore info/debug output */
+               if (!msgs2stderr)
+                       negate_output_levels(); /* restore info/debug output */
+               /* If the sender is going to send us an MSG_IO_ERROR value, it
+                * will always be the very next message following a file list. */
+               if (delete_during)
+                       check_for_io_err = 1;
        }
 
        iflags = protocol_version >= 29 ? read_shortint(f_in)