summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2007-08-30 08:15:37 +0000
committerMartin Rudalics <rudalics@gmx.at>2007-08-30 08:15:37 +0000
commita44a7d8eb470a08894f7f688a2a165afb8af6893 (patch)
treeaee0b67cdb4a7ac05cb6cf512a107279105aacce /lisp/files.el
parent7d88961c6dbe007d289db061df42d8c0ff96e932 (diff)
downloademacs-a44a7d8eb470a08894f7f688a2a165afb8af6893.tar.gz
(backup-buffer-copy): Try to overwrite old backup first.
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el28
1 files changed, 16 insertions, 12 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 69ebf460781..bc482c8f37b 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3127,18 +3127,22 @@ BACKUPNAME is the backup file name, which is the old file renamed."
;; loosen them later, whereas it's impossible to close the
;; time-window of loose permissions otherwise.
(set-default-file-modes ?\700)
- (while (condition-case ()
- (progn
- (and (file-exists-p to-name)
- (delete-file to-name))
- (copy-file from-name to-name nil t)
- nil)
- (file-already-exists t))
- ;; The file was somehow created by someone else between
- ;; `delete-file' and `copy-file', so let's try again.
- ;; rms says "I think there is also a possible race
- ;; condition for making backup files" (emacs-devel 20070821).
- nil))
+ (when (condition-case nil
+ ;; Try to overwrite old backup first.
+ (copy-file from-name to-name t t)
+ (error t))
+ (while (condition-case nil
+ (progn
+ (when (file-exists-p to-name)
+ (delete-file to-name))
+ (copy-file from-name to-name nil t)
+ nil)
+ (file-already-exists t))
+ ;; The file was somehow created by someone else between
+ ;; `delete-file' and `copy-file', so let's try again.
+ ;; rms says "I think there is also a possible race
+ ;; condition for making backup files" (emacs-devel 20070821).
+ nil)))
;; Reset the umask.
(set-default-file-modes umask)))
(and modes