Hit the "not a regular file (recv_files)" error last night
having replaced a directory with a file.

The really dumb part is that this was hit doing a link-dest
on an empty destination so the robust_unlink would have
presented no problem anyway.

I can see no reason why non-directory special files should
have any problem being replaced so i've changed that logic too.

The new code simply treats old non-directory special files
as though they were non-existent and the same for
directories if they aren't in the destination (coming from
link-dest or compare-dest.

As the new comment in the patch indicates, we wouldn't have
this problem at all if robust_unlink could cope with
non-empty directories.

Barring comments or objections i'll commit this soon.


Index: receiver.c
===================================================================
RCS file: /data/cvs/rsync/receiver.c,v
retrieving revision 1.51
diff -u -r1.51 receiver.c
--- receiver.c  21 Aug 2003 23:45:49 -0000      1.51
+++ receiver.c  2 Sep 2003 23:29:13 -0000
@@ -419,11 +419,23 @@
                        continue;
                }
 
-               if (fd1 != -1 && !S_ISREG(st.st_mode)) {
-                       rprintf(FERROR,"%s : not a regular file 
(recv_files)\n",fnamecmp);
-                       receive_data(f_in,NULL,-1,NULL,file->length);
+               if (fd1 != -1 && S_ISDIR(st.st_mode) && fnamecmp == fname) {
+                       /* this special handling for directories
+                        * wouldn't be necessary if robust_rename()
+                        * and the underlying robust_unlink could cope
+                        * with directories
+                        */
+                       rprintf(FERROR,"%s : is a directory (recv_files)\n",
+                           fnamecmp);
+                       receive_data(f_in, NULL, -1, NULL, file->length);
                        close(fd1);
                        continue;
+               }
+
+               if (fd1 != -1 && !S_ISREG(st.st_mode)) {
+                       close(fd1);
+                       fd1 = -1;
+                       buf = NULL;
                }
 
                if (fd1 != -1 && !preserve_perms) {
-- 
________________________________________________________________
        J.W. Schultz            Pegasystems Technologies
        email address:          [EMAIL PROTECTED]

                Remember Cernan and Schmitt
-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to