emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7bcf7b8e20e: Improve Tramp for remote WebDAV


From: Michael Albinus
Subject: master 7bcf7b8e20e: Improve Tramp for remote WebDAV
Date: Sat, 1 Jul 2023 04:19:50 -0400 (EDT)

branch: master
commit 7bcf7b8e20eb41ba2a0ecd134a795928786b1d41
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Improve Tramp for remote WebDAV
    
    * lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file):
    * lisp/net/tramp-rclone.el (tramp-rclone-do-copy-or-rename-file):
    Improve stability for WebDAV.
---
 lisp/net/tramp-gvfs.el   |  2 ++
 lisp/net/tramp-rclone.el | 24 ++++++++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 48467a92c14..27dbf324924 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1068,6 +1068,8 @@ file names."
          (when (and (file-directory-p newname)
                     (not (directory-name-p newname)))
            (tramp-error v 'file-error "File is a directory %s" newname))
+         (when (file-regular-p newname)
+           (delete-file newname))
 
          (cond
           ;; We cannot rename volatile files, as used by Google-drive.
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index f71e4f732e2..df46bd5e20e 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -226,6 +226,7 @@ file names."
 
     (let ((t1 (tramp-tramp-file-p filename))
          (t2 (tramp-tramp-file-p newname))
+         (equal-remote (tramp-equal-remote filename newname))
          (rclone-operation (if (eq op 'copy) "copyto" "moveto"))
          (msg-operation (if (eq op 'copy) "Copying" "Renaming")))
 
@@ -236,8 +237,12 @@ file names."
          (when (and (file-directory-p newname)
                     (not (directory-name-p newname)))
            (tramp-error v 'file-error "File is a directory %s" newname))
+         (when (file-regular-p newname)
+           (delete-file newname))
 
-         (if (or (and t1 (not (tramp-rclone-file-name-p filename)))
+         (if (or (and equal-remote
+                      (tramp-get-connection-property v "direct-copy-failed"))
+                 (and t1 (not (tramp-rclone-file-name-p filename)))
                  (and t2 (not (tramp-rclone-file-name-p newname))))
 
              ;; We cannot copy or rename directly.
@@ -257,9 +262,20 @@ file names."
                        v rclone-operation
                        (tramp-rclone-remote-file-name filename)
                        (tramp-rclone-remote-file-name newname)))
-               (tramp-error
-                v 'file-error
-                "Error %s `%s' `%s'" msg-operation filename newname)))
+               (if (or (not equal-remote)
+                       (and equal-remote
+                            (tramp-get-connection-property
+                             v "direct-copy-failed")))
+                   (tramp-error
+                    v 'file-error
+                    "Error %s `%s' `%s'" msg-operation filename newname)
+
+                 ;; Some WebDAV server, like the one from QNAP, do
+                 ;; not support direct copy/move.  Try a fallback.
+                 (tramp-set-connection-property v "direct-copy-failed" t)
+                 (tramp-rclone-do-copy-or-rename-file
+                  op filename newname ok-if-already-exists keep-date
+                  preserve-uid-gid preserve-extended-attributes))))
 
            (when (and t1 (eq op 'rename))
              (while (file-exists-p filename)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]