2005-02-10 Yuuichi Teranishi <teranisi@gohome.org>
+ * 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'.
(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 <lapis-lazuli@pop06.odn.ne.jp>
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))
(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))
(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))