- if (do_mkdir(name,0777 & ~orig_umask) != 0) {
- rsyserr(FERROR, errno, "mkdir %s failed", full_fname(name));
- exit_cleanup(RERR_FILEIO);
- }
- if (verbose > 0)
- rprintf(FINFO, "created directory %s\n", safe_fname(name));
+ /* If the destination path ends in a slash or we are transferring
+ * multiple files, create a directory at the destination path,
+ * enter the new directory, and use mode 1. */
+ if (flist->count > 1 || (cp && !cp[1])) {
+ /* Lop off the final slash (if any). */
+ if (cp && !cp[1])
+ *cp = '\0';
+
+ umask(orig_umask);
+ if (do_mkdir(dest_path, 0777) != 0) {
+ rsyserr(FERROR, errno, "mkdir %s failed",
+ full_fname(dest_path));
+ exit_cleanup(RERR_FILEIO);
+ }
+ umask(0);
+
+ if (verbose)
+ rprintf(FINFO, "created directory %s\n", dest_path);
+
+ if (dry_run) {
+ /* Indicate that the destination directory doesn't
+ * really exist and return mode 1. */
+ dry_run++;
+ return NULL;
+ }
+
+ if (!push_dir(dest_path)) {
+ rsyserr(FERROR, errno, "push_dir#2 %s failed",
+ full_fname(dest_path));
+ exit_cleanup(RERR_FILESELECT);
+ }