From: teranisi Date: Thu, 10 Feb 2005 23:53:07 +0000 (+0000) Subject: * elmo-maildir.el (elmo-maildir-move-file): New function. X-Git-Tag: wl-2_14-root~56 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=61878895a4897bb65aea9b6e611139d25e3e448e;p=elisp%2Fwanderlust.git * elmo-maildir.el (elmo-maildir-move-file): New function. (elmo-folder-append-buffer): Use it. (elmo-folder-append-messages): Ditto. (These changes are based on Ron Isaacson's patch [wl-en: 01205]) --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 1723509..bbddd95 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,5 +1,10 @@ 2005-02-10 Yuuichi Teranishi + * elmo-maildir.el (elmo-maildir-move-file): New function. + (elmo-folder-append-buffer): Use it. + (elmo-folder-append-messages): Ditto. + (These changes are based on Ron Isaacson's patch [wl-en: 01205]) + * elmo-imap4.el (elmo-imap4-decode-folder-string): Call `utf7-decode'. (elmo-imap4-encode-folder-string): Call `utf7-encode'. @@ -9,7 +14,7 @@ (elmo-maildir-update-current): Ditto. (elmo-maildir-set-mark): Ditto. (elmo-maildir-delete-mark): Ditto. - (Above changes are based on Hiroya Murata's patch [wl: 13437]) + (These changes are based on Hiroya Murata's patch [wl: 13437]) 2005-02-06 Hiroya Murata diff --git a/elmo/elmo-maildir.el b/elmo/elmo-maildir.el index 29de0b7..7e2fb56 100644 --- a/elmo/elmo-maildir.el +++ b/elmo/elmo-maildir.el @@ -416,6 +416,29 @@ file name for maildir directories." basedir))) filename)) +(defun elmo-maildir-move-file (src dst) + (or (and (fboundp 'make-symbolic-link) + ;; 1. If make-symbolic-link is defined, then assume the system has + ;; hardlinks and try add-link-to-file, then delete the original. + ;; This is safe on NFS. + (condition-case nil + (progn + (add-name-to-file src dst) + t) + (error)) + ;; It's ok if the delete-file fails; + ;; elmo-maildir-cleanup-temporal will catch it later. + (progn + (condition-case nil + (delete-file src) + (error)) + ;; Exit this function anyway. + t)) + ;; 2. Even on systems with hardlinks, some filesystems (like AFS) + ;; might not support them, so fall back on rename-file. This is + ;; our best shot at atomic when add-name-to-file fails. + (rename-file src dst))) + (luna-define-method elmo-folder-append-buffer ((folder elmo-maildir-folder) &optional flags number) (let ((basedir (elmo-maildir-folder-directory-internal folder)) @@ -429,10 +452,7 @@ file name for maildir directories." (copy-to-buffer dst-buf (point-min) (point-max))) (as-binary-output-file (write-region (point-min) (point-max) filename nil 'no-msg)) - ;; add link from new. - ;; Some filesystem (like AFS) does not have hard-link. - ;; So we use elmo-copy-file instead of elmo-add-name-to-file here. - (elmo-copy-file + (elmo-maildir-move-file filename (expand-file-name (concat "new/" (file-name-nondirectory filename)) @@ -486,9 +506,7 @@ file name for maildir directories." (elmo-copy-file (elmo-message-file-name src-folder number) filename) - ;; Some filesystem (like AFS) does not have hard-link. - ;; So we use elmo-copy-file instead of elmo-add-name-to-file here. - (elmo-copy-file + (elmo-maildir-move-file filename (expand-file-name (concat "new/" (file-name-nondirectory filename))