From 07da629926daf849aab248175c88cf53a5e21558 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 26 Feb 2020 17:10:21 -0800 Subject: [PATCH] nnmail-cache-close should not use nofollow MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit nnmail-cache-close did not work when ~/.nnmail-cache was a symlink to some other directory. Reported by Michael Albinus (Bug#39793). * lisp/gnus/nnbabyl.el (nnbabyl-create-mbox): * lisp/gnus/nndiary.el (nndiary-generate-nov-file): * lisp/gnus/nnfolder.el (nnfolder-possibly-change-group): * lisp/gnus/nnmbox.el (nnmbox-create-mbox): * lisp/gnus/nnml.el (nnml-generate-nov-file): Pass ‘excl’ to nnmail-write-region when creating a file, for safety. * lisp/gnus/nnmail.el (nnmail-write-region): Add optional MUSTBENEW arg, to stay consistent with write-region. Past ‘nofollow’ to set-file-modes only when MUSTBENEW is ‘excl’. --- lisp/gnus/nnbabyl.el | 2 +- lisp/gnus/nndiary.el | 2 +- lisp/gnus/nnfolder.el | 2 +- lisp/gnus/nnmail.el | 8 +++++--- lisp/gnus/nnmbox.el | 2 +- lisp/gnus/nnml.el | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lisp/gnus/nnbabyl.el b/lisp/gnus/nnbabyl.el index cb22933b529..480d794b9ac 100644 --- a/lisp/gnus/nnbabyl.el +++ b/lisp/gnus/nnbabyl.el @@ -544,7 +544,7 @@ (setq buffer-file-name nnbabyl-mbox-file) (insert "BABYL OPTIONS:\n\n\^_") (nnmail-write-region - (point-min) (point-max) nnbabyl-mbox-file t 'nomesg)))) + (point-min) (point-max) nnbabyl-mbox-file t 'nomesg nil 'excl)))) (defun nnbabyl-read-mbox () (nnmail-activate 'nnbabyl) diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el index ac394ae53d7..945ef0351e5 100644 --- a/lisp/gnus/nndiary.el +++ b/lisp/gnus/nndiary.el @@ -1115,7 +1115,7 @@ all. This may very well take some time.") (widen)) (setq files (cdr files))) (with-current-buffer nov-buffer - (nnmail-write-region 1 (point-max) nov nil 'nomesg) + (nnmail-write-region 1 (point-max) nov nil 'nomesg nil 'excl) (kill-buffer (current-buffer)))))) (defun nndiary-nov-delete-article (group article) diff --git a/lisp/gnus/nnfolder.el b/lisp/gnus/nnfolder.el index d1eeb04697e..c27af1742d8 100644 --- a/lisp/gnus/nnfolder.el +++ b/lisp/gnus/nnfolder.el @@ -735,7 +735,7 @@ deleted. Point is left where the deleted region was." (or nnfolder-file-coding-system-for-write nnfolder-file-coding-system-for-write))) (nnmail-write-region (point-min) (point-min) - file t 'nomesg))) + file t 'nomesg nil 'excl))) (when (setq nnfolder-current-buffer (nnfolder-read-folder group)) (set-buffer nnfolder-current-buffer) (push (list group nnfolder-current-buffer) diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el index 93e4b0e7a8f..3be843c91f1 100644 --- a/lisp/gnus/nnmail.el +++ b/lisp/gnus/nnmail.el @@ -1953,12 +1953,14 @@ If TIME is nil, then return the cutoff time for oldness instead." (unless (re-search-forward "^Message-ID[ \t]*:" nil t) (insert "Message-ID: " (nnmail-message-id) "\n"))))) -(defun nnmail-write-region (start end filename &optional append visit lockname) +(defun nnmail-write-region (start end filename + &optional append visit lockname mustbenew) "Do a `write-region', and then set the file modes." (let ((coding-system-for-write nnmail-file-coding-system) (file-name-coding-system nnmail-pathname-coding-system)) - (write-region start end filename append visit lockname) - (set-file-modes filename nnmail-default-file-modes 'nofollow))) + (write-region start end filename append visit lockname mustbenew) + (set-file-modes filename nnmail-default-file-modes + (when (eq mustbenew 'excl) 'nofollow)))) ;;; ;;; Status functions diff --git a/lisp/gnus/nnmbox.el b/lisp/gnus/nnmbox.el index a191f887c78..8b3d80266e7 100644 --- a/lisp/gnus/nnmbox.el +++ b/lisp/gnus/nnmbox.el @@ -613,7 +613,7 @@ (dir (file-name-directory nnmbox-mbox-file))) (and dir (gnus-make-directory dir)) (nnmail-write-region (point-min) (point-min) - nnmbox-mbox-file t 'nomesg)))) + nnmbox-mbox-file t 'nomesg nil 'excl)))) (defun nnmbox-read-mbox () (nnmail-activate 'nnmbox) diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el index 2c39ab8e36a..baf5d54b74d 100644 --- a/lisp/gnus/nnml.el +++ b/lisp/gnus/nnml.el @@ -901,7 +901,7 @@ Unless no-active is non-nil, update the active file too." (nnheader-insert-nov headers))) (widen)))) (with-current-buffer nov-buffer - (nnmail-write-region (point-min) (point-max) nov nil 'nomesg) + (nnmail-write-region (point-min) (point-max) nov nil 'nomesg nil 'excl) (kill-buffer (current-buffer)))))) (defun nnml-nov-delete-article (group article) -- 2.39.2