Allow non-dir special files to be replaced with regular
authorJ.W. Schultz <jw@samba.org>
Thu, 4 Sep 2003 05:49:50 +0000 (05:49 +0000)
committerJ.W. Schultz <jw@samba.org>
Thu, 4 Sep 2003 05:49:50 +0000 (05:49 +0000)
files and fix error that caused directories in link-dest or
compare-dest to prevent the creation of files of same path.

receiver.c

index be433ae..aa3c659 100644 (file)
@@ -419,13 +419,25 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
                        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) {
                        /* if the file exists already and we aren't preserving
                           permissions then act as though the remote end sent