diff options
| author | Ken Olum | 2016-05-28 13:46:22 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-05-28 13:46:22 +0300 |
| commit | 549470fdf234acb4da7941e3bb9b28ed63a51876 (patch) | |
| tree | dff95e89eaa065df2a072fdfc73285b1514d10a2 | |
| parent | 062757dca01cff127583438ae16237af55b6253c (diff) | |
| download | emacs-549470fdf234acb4da7941e3bb9b28ed63a51876.tar.gz emacs-549470fdf234acb4da7941e3bb9b28ed63a51876.zip | |
Prevent locked-file errors in Rmail
* lisp/mail/rmail.el (rmail-get-new-mail-1): Lock file before
calling 'rmail-insert-inbox-text'. Unlock if
'rmail-insert-inbox-text' doesn't modify buffer.
(rmail-insert-inbox-text): Remove lock-checking code. (Bug#17706)
| -rw-r--r-- | lisp/mail/rmail.el | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 734155e217d..e9882253c70 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -1818,9 +1818,21 @@ not be a new one). It returns non-nil if it got any new messages." | |||
| 1818 | ;; Read in the contents of the inbox files, renaming them as | 1818 | ;; Read in the contents of the inbox files, renaming them as |
| 1819 | ;; necessary, and adding to the list of files to delete | 1819 | ;; necessary, and adding to the list of files to delete |
| 1820 | ;; eventually. | 1820 | ;; eventually. |
| 1821 | (if file-name | 1821 | (unwind-protect |
| 1822 | (rmail-insert-inbox-text files nil) | 1822 | (progn |
| 1823 | (setq delete-files (rmail-insert-inbox-text files t))) | 1823 | ;; Set modified now to lock the file, so that we don't |
| 1824 | ;; encounter locking problems later in the middle of | ||
| 1825 | ;; reading the mail. | ||
| 1826 | (set-buffer-modified-p t) | ||
| 1827 | (if file-name | ||
| 1828 | (rmail-insert-inbox-text files nil) | ||
| 1829 | (setq delete-files (rmail-insert-inbox-text files t)))) | ||
| 1830 | ;; If there was no new mail, or we aborted before actually | ||
| 1831 | ;; trying to get any, mark buffer unmodified. Otherwise the | ||
| 1832 | ;; buffer is correctly marked modified and the file locked | ||
| 1833 | ;; until we save out the new mail. | ||
| 1834 | (if (= (point-min) (point-max)) | ||
| 1835 | (set-buffer-modified-p nil))) | ||
| 1824 | ;; Scan the new text and convert each message to | 1836 | ;; Scan the new text and convert each message to |
| 1825 | ;; Rmail/mbox format. | 1837 | ;; Rmail/mbox format. |
| 1826 | (goto-char (point-min)) | 1838 | (goto-char (point-min)) |
| @@ -1969,11 +1981,6 @@ Value is the size of the newly read mail after conversion." | |||
| 1969 | size)) | 1981 | size)) |
| 1970 | 1982 | ||
| 1971 | (defun rmail-insert-inbox-text (files renamep) | 1983 | (defun rmail-insert-inbox-text (files renamep) |
| 1972 | ;; Detect a locked file now, so that we avoid moving mail | ||
| 1973 | ;; out of the real inbox file. (That could scare people.) | ||
| 1974 | (or (memq (file-locked-p buffer-file-name) '(nil t)) | ||
| 1975 | (error "RMAIL file %s is locked" | ||
| 1976 | (file-name-nondirectory buffer-file-name))) | ||
| 1977 | (let (file tofile delete-files popmail got-password password) | 1984 | (let (file tofile delete-files popmail got-password password) |
| 1978 | (while files | 1985 | (while files |
| 1979 | ;; Handle remote mailbox names specially; don't expand as filenames | 1986 | ;; Handle remote mailbox names specially; don't expand as filenames |