* files.el (move-file-to-trash): Preserve default file modes on error.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 29 Dec 2011 21:08:18 +0000 (13:08 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 29 Dec 2011 21:08:18 +0000 (13:08 -0800)
lisp/ChangeLog
lisp/files.el

index 37286d0..d1f0019 100644 (file)
@@ -1,3 +1,7 @@
+2011-12-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * files.el (move-file-to-trash): Preserve default file modes on error.
+
 2011-12-29  Michael Albinus  <michael.albinus@gmx.de>
 
        * net/tramp-sh.el (tramp-find-shell): Set "remote-shell" property
index 0f73865..4cb0336 100644 (file)
@@ -6457,12 +6457,14 @@ Otherwise, trash FILENAME using the freedesktop.org conventions,
 
           ;; Ensure that the trash directory exists; otherwise, create it.
           (let ((saved-default-file-modes (default-file-modes)))
-            (set-default-file-modes ?\700)
-            (unless (file-exists-p trash-files-dir)
-              (make-directory trash-files-dir t))
-            (unless (file-exists-p trash-info-dir)
-              (make-directory trash-info-dir t))
-            (set-default-file-modes saved-default-file-modes))
+            (unwind-protect
+                (progn
+                  (set-default-file-modes #o700)
+                  (unless (file-exists-p trash-files-dir)
+                    (make-directory trash-files-dir t))
+                  (unless (file-exists-p trash-info-dir)
+                    (make-directory trash-info-dir t)))
+              (set-default-file-modes saved-default-file-modes)))
 
           ;; Try to move to trash with .trashinfo undo information
           (save-excursion