(signal (car err) (cdr err))))
;; Remote newname.
- (when (file-directory-p newname)
+ (when (and (file-directory-p newname)
+ (directory-name-p newname))
(setq newname
(expand-file-name
(file-name-nondirectory filename) newname)))
(tramp-dissect-file-name newname)))))
;; scp or rsync DTRT.
(progn
+ (when (and (file-directory-p newname)
+ (not (directory-name-p newname)))
+ (tramp-error v 'file-already-exists newname))
(setq dirname (directory-file-name (expand-file-name dirname))
newname (directory-file-name (expand-file-name newname)))
- (if (and (file-directory-p newname)
- (not (string-equal (file-name-nondirectory dirname)
- (file-name-nondirectory newname))))
- (setq newname
- (expand-file-name
- (file-name-nondirectory dirname) newname)))
- (if (not (file-directory-p (file-name-directory newname)))
+ (when (and (file-directory-p newname)
+ (not (string-equal (file-name-nondirectory dirname)
+ (file-name-nondirectory newname))))
+ (setq newname
+ (expand-file-name
+ (file-name-nondirectory dirname) newname)))
+ (when (not (file-directory-p (file-name-directory newname)))
(make-directory (file-name-directory newname) parents))
(tramp-do-copy-or-rename-file-out-of-band
'copy dirname newname keep-date))
+
;; We must do it file-wise.
(tramp-run-real-handler
'copy-directory
- (if copy-contents
- (list dirname newname keep-date parents copy-contents)
- (list dirname newname keep-date parents))))
+ (list dirname newname keep-date parents copy-contents)))
;; When newname did exist, we have wrong cached values.
(when t2
(with-parsed-tramp-file-name (if t1 dirname newname) nil
(with-tramp-progress-reporter
v 0 (format "Copying %s to %s" dirname newname)
+ (when (and (file-directory-p newname)
+ (not (directory-name-p newname)))
+ (tramp-error v 'file-already-exists newname))
(cond
;; We must use a local temporary directory.
((and t1 t2)
(unwind-protect
(progn
(make-directory tmpdir)
- (copy-directory dirname tmpdir keep-date 'parents)
+ (copy-directory
+ dirname (file-name-as-directory tmpdir) keep-date 'parents)
(copy-directory
(expand-file-name (file-name-nondirectory dirname) tmpdir)
newname keep-date parents))
0 (format "Copying %s to %s" filename newname)
(if (file-directory-p filename)
- (copy-directory
- filename newname keep-date 'parents 'copy-contents)
+ (copy-directory filename newname keep-date 'parents 'copy-contents)
(let ((tmpfile (file-local-copy filename)))
(if tmpfile
(signal (car err) (cdr err))))
;; Remote newname.
- (when (file-directory-p newname)
+ (when (and (file-directory-p newname)
+ (directory-name-p newname))
(setq newname
(expand-file-name (file-name-nondirectory filename) newname)))