emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/lisp/net tramp.el


From: Michael Albinus
Subject: [Emacs-diffs] emacs/lisp/net tramp.el
Date: Mon, 05 Jan 2009 19:37:01 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Michael Albinus <albinus>       09/01/05 19:37:01

Modified files:
        lisp/net       : tramp.el 

Log message:
        * net/tramp.el (tramp-handle-load)
        (tramp-do-copy-or-rename-file-directly)
        (tramp-handle-file-local-copy, tramp-handle-insert-file-contents)
        (tramp-handle-write-region): Delete temporary file in case of
        error.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/net/tramp.el?cvsroot=emacs&r1=1.220&r2=1.221

Patches:
Index: tramp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/tramp.el,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -b -r1.220 -r1.221
--- tramp.el    5 Jan 2009 02:00:23 -0000       1.220
+++ tramp.el    5 Jan 2009 19:37:01 -0000       1.221
@@ -2263,8 +2263,9 @@
       (unless nomessage (tramp-message v 0 "Loading %s..." file))
       (let ((local-copy (file-local-copy file)))
        ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
+       (unwind-protect
        (load local-copy noerror t t)
-       (delete-file local-copy))
+         (delete-file local-copy)))
       (unless nomessage (tramp-message v 0 "Loading %s...done" file))
       t)))
 
@@ -3258,6 +3259,7 @@
 
           ;; We need a temporary file in between.
           (t
+           (condition-case err
            ;; Create the temporary file.
            (let ((tmpfile (tramp-compat-make-temp-file localname1)))
              (cond
@@ -3278,7 +3280,8 @@
                     localname1 tmpfile ok-if-already-exists
                     keep-date preserve-uid-gid)
                  (tramp-run-real-handler
-                  'rename-file (list localname1 tmpfile ok-if-already-exists)))
+                      'rename-file
+                      (list localname1 tmpfile ok-if-already-exists)))
                ;; We must change the ownership as local user.
                (tramp-set-file-uid-gid
                 tmpfile
@@ -3296,7 +3299,11 @@
               (t1
                (tramp-run-real-handler
                 'rename-file
-                (list tmpfile localname2 ok-if-already-exists))))))))))
+                    (list tmpfile localname2 ok-if-already-exists)))))
+
+             ;; Error handling.
+             (error (delete-file tmpfile)
+                    (signal (car err) (cdr err)))))))))
 
       ;; Set the time and mode. Mask possible errors.
       ;; Won't be applied for 'rename.
@@ -4051,8 +4058,9 @@
              (tramp-message
               v 5 "Decoding remote file %s with command %s..."
               filename loc-dec)
+             (unwind-protect
              (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile)
-             (delete-file tmpfile2)))
+               (delete-file tmpfile2))))
          (tramp-message v 5 "Decoding remote file %s...done" filename)
          ;; Set proper permissions.
          (set-file-modes tmpfile (file-modes filename))
@@ -4134,6 +4142,7 @@
            (tramp-message v 4 "Inserting local temp file `%s'..." local-copy)
            ;; We must ensure that `file-coding-system-alist' matches
            ;; `local-copy'.
+           (unwind-protect
            (let ((file-coding-system-alist
                   (tramp-find-file-name-coding-system-alist
                    filename local-copy)))
@@ -4143,9 +4152,9 @@
              (when (boundp 'last-coding-system-used)
                (setq coding-system-used
                      (symbol-value 'last-coding-system-used))))
+             (delete-file local-copy))
            (tramp-message
             v 4 "Inserting local temp file `%s'...done" local-copy)
-           (delete-file local-copy)
            (when (boundp 'last-coding-system-used)
              (set 'last-coding-system-used coding-system-used))))
 
@@ -4333,9 +4342,13 @@
          ;; matches `tmpfile'.
          (let ((file-coding-system-alist
                 (tramp-find-file-name-coding-system-alist filename tmpfile)))
+           (condition-case err
            (tramp-run-real-handler
             'write-region
             (list start end tmpfile append 'no-message lockname confirm))
+             (error (delete-file tmpfile)
+                    (signal (car err) (cdr err))))
+
            ;; Now, `last-coding-system-used' has the right value.  Remember it.
            (when (boundp 'last-coding-system-used)
              (setq coding-system-used
@@ -4360,7 +4373,10 @@
                (and (tramp-method-out-of-band-p v)
                     (> (- (or end (point-max)) (or start (point-min)))
                        tramp-copy-size-limit)))
-           (rename-file tmpfile filename t))
+           (condition-case err
+               (rename-file tmpfile filename t)
+             (error (delete-file tmpfile)
+                    (signal (car err) (cdr err)))))
 
           ;; Use inline file transfer.
           (rem-dec




reply via email to

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