From 2c418c5bbfbf2b9feb036f92657471db9567a483 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 6 Jan 2009 07:56:42 +0000 Subject: [PATCH] * net/tramp-smb.el (tramp-smb-handle-copy-file) (tramp-smb-handle-rename-file): Delete temporary file in case of quit. --- lisp/ChangeLog | 8 ++++ lisp/net/tramp-smb.el | 10 +++-- lisp/net/tramp.el | 87 ++++++++++++++++++++++--------------------- 3 files changed, 58 insertions(+), 47 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5267a905bdc..e404bceba07 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2009-01-06 Michael Albinus + + * net/tramp.el (tramp-do-copy-or-rename-file-directly) + (tramp-handle-file-local-copy, tramp-handle-write-region) + * net/tramp-smb.el (tramp-smb-handle-copy-file) + (tramp-smb-handle-rename-file): Delete temporary file in case of + quit. + 2009-01-06 Stefan Monnier * minibuffer.el (completion-hilit-commonality): Don't presume diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index b9dc8731215..41f4c25318a 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -218,8 +218,9 @@ PRESERVE-UID-GID is completely ignored." ;; Remote filename. (condition-case err (rename-file tmpfile newname ok-if-already-exists) - (error (delete-file tmpfile) - (signal (car err) (cdr err)))) + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err)))) ;; Remote newname. (when (file-directory-p newname) @@ -554,8 +555,9 @@ PRESERVE-UID-GID is completely ignored." ;; Remote filename. (condition-case err (rename-file tmpfile newname ok-if-already-exists) - (error (delete-file tmpfile) - (signal (car err) (cdr err)))) + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err)))) ;; Remote newname. (when (file-directory-p newname) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 04781c7b2c2..b226f22ad98 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3259,52 +3259,53 @@ the uid and gid from FILENAME." ;; We need a temporary file in between. (t - (condition-case err - ;; Create the temporary file. - (let ((tmpfile (tramp-compat-make-temp-file localname1))) - (cond - (t1 - (tramp-send-command - v (format - "%s %s %s" cmd - (tramp-shell-quote-argument localname1) - (tramp-shell-quote-argument tmpfile))) - ;; We must change the ownership as remote user. - (tramp-set-file-uid-gid - (concat prefix tmpfile) - (tramp-get-local-uid 'integer) - (tramp-get-local-gid 'integer))) - (t2 - (if (eq op 'copy) - (tramp-compat-copy-file - localname1 tmpfile ok-if-already-exists - keep-date preserve-uid-gid) + ;; Create the temporary file. + (let ((tmpfile (tramp-compat-make-temp-file localname1))) + (condition-case err + (progn + (cond + (t1 + (tramp-send-command + v (format + "%s %s %s" cmd + (tramp-shell-quote-argument localname1) + (tramp-shell-quote-argument tmpfile))) + ;; We must change the ownership as remote user. + (tramp-set-file-uid-gid + (concat prefix tmpfile) + (tramp-get-local-uid 'integer) + (tramp-get-local-gid 'integer))) + (t2 + (if (eq op 'copy) + (tramp-compat-copy-file + localname1 tmpfile ok-if-already-exists + keep-date preserve-uid-gid) + (tramp-run-real-handler + 'rename-file + (list localname1 tmpfile ok-if-already-exists))) + ;; We must change the ownership as local user. + (tramp-set-file-uid-gid + tmpfile + (tramp-get-remote-uid v 'integer) + (tramp-get-remote-gid v 'integer)))) + + ;; Move the temporary file to its destination. + (cond + (t2 + (tramp-send-command + v (format + "mv -f %s %s" + (tramp-shell-quote-argument tmpfile) + (tramp-shell-quote-argument localname2)))) + (t1 (tramp-run-real-handler 'rename-file - (list localname1 tmpfile ok-if-already-exists))) - ;; We must change the ownership as local user. - (tramp-set-file-uid-gid - tmpfile - (tramp-get-remote-uid v 'integer) - (tramp-get-remote-gid v 'integer)))) - - ;; Move the temporary file to its destination. - (cond - (t2 - (tramp-send-command - v (format - "mv -f %s %s" - (tramp-shell-quote-argument tmpfile) - (tramp-shell-quote-argument localname2)))) - (t1 - (tramp-run-real-handler - 'rename-file - (list tmpfile localname2 ok-if-already-exists))))) + (list tmpfile localname2 ok-if-already-exists))))) - ;; Error handling. - ((error quit) - (delete-file tmpfile) - (signal (car err) (cdr err))))))))) + ;; Error handling. + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err)))))))))) ;; Set the time and mode. Mask possible errors. ;; Won't be applied for 'rename. -- 2.39.2