mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-06 04:09:37 +00:00
Fix a couple of make-temp-file races
* lisp/emacs-lisp/autoload.el (autoload--save-buffer): * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Use make-temp-file, not make-temp-name, to avoid an unlikely race that could lose data. Remove the deletion hook as quickly as possible after the file is renamed; though a race still remains here, it is smaller than before.
This commit is contained in:
parent
c0df64db08
commit
785a4a1d52
2 changed files with 26 additions and 24 deletions
|
@ -875,16 +875,16 @@ FILE's modification time."
|
|||
"Save current buffer to its file, atomically."
|
||||
;; Copied from byte-compile-file.
|
||||
(let* ((version-control 'never)
|
||||
(tempfile (make-temp-name buffer-file-name))
|
||||
(tempfile (make-temp-file buffer-file-name))
|
||||
(kill-emacs-hook
|
||||
(cons (lambda () (ignore-errors (delete-file tempfile)))
|
||||
kill-emacs-hook)))
|
||||
(write-region (point-min) (point-max) tempfile nil 1)
|
||||
(backup-buffer)
|
||||
(rename-file tempfile buffer-file-name t)
|
||||
(set-buffer-modified-p nil)
|
||||
(set-visited-file-modtime)
|
||||
(or noninteractive (message "Wrote %s" buffer-file-name))))
|
||||
(rename-file tempfile buffer-file-name t))
|
||||
(set-buffer-modified-p nil)
|
||||
(set-visited-file-modtime)
|
||||
(or noninteractive (message "Wrote %s" buffer-file-name)))
|
||||
|
||||
(defun autoload-save-buffers ()
|
||||
(while autoload-modified-buffers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue