[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/sqlite 2767a7e: Write+rename instead of just writing in the file
From: |
Lars Ingebrigtsen |
Subject: |
scratch/sqlite 2767a7e: Write+rename instead of just writing in the file backend |
Date: |
Tue, 14 Dec 2021 08:36:45 -0500 (EST) |
branch: scratch/sqlite
commit 2767a7e314dc48acd4f341ce88d906c242a1165b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Write+rename instead of just writing in the file backend
---
lisp/emacs-lisp/multisession.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/multisession.el b/lisp/emacs-lisp/multisession.el
index 815e87f..9ffb300 100644
--- a/lisp/emacs-lisp/multisession.el
+++ b/lisp/emacs-lisp/multisession.el
@@ -280,9 +280,13 @@ DOC should be a doc string, and ARGS are keywords as
applicable to
(print-circle t)
(print-level nil))
(prin1 value (current-buffer)))
+ ;; Write to a temp file in the same directory and rename to the
+ ;; file for somewhat better atomicity.
(let ((coding-system-for-write 'utf-8)
- (create-lockfiles nil))
- (write-region (point-min) (point-max) file nil 'silent)))
+ (create-lockfiles nil)
+ (temp (make-temp-name file)))
+ (write-region (point-min) (point-max) temp nil 'silent)
+ (rename-file temp file t)))
(setf (multisession--cached-sequence object) time
(multisession--cached-value object) value)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/sqlite 2767a7e: Write+rename instead of just writing in the file backend,
Lars Ingebrigtsen <=