(nconc (car msgdb) (car msgdb-append))
(nconc (cadr msgdb) (cadr msgdb-append))
(nconc (caddr msgdb) (caddr msgdb-append))
- (elmo-msgdb-make-index
+ (elmo-msgdb-make-index-return
msgdb
(elmo-msgdb-get-overview msgdb-append)
(elmo-msgdb-get-mark-alist msgdb-append))
(nth 4 msgdb)))
+(defun elmo-msgdb-merge (folder msgdb-merge)
+ "Return a list of messages which have duplicated message-id."
+ (let (msgdb duplicates)
+ (setq msgdb (or (elmo-folder-msgdb-internal folder)
+ (elmo-make-msgdb nil nil nil
+ (elmo-folder-msgdb-path folder))))
+ (elmo-msgdb-set-overview
+ msgdb
+ (nconc (elmo-msgdb-get-overview msgdb)
+ (elmo-msgdb-get-overview msgdb-merge)))
+ (elmo-msgdb-set-number-alist
+ msgdb
+ (nconc (elmo-msgdb-get-number-alist msgdb)
+ (elmo-msgdb-get-number-alist msgdb-merge)))
+ (elmo-msgdb-set-mark-alist
+ msgdb
+ (nconc (elmo-msgdb-get-mark-alist msgdb)
+ (elmo-msgdb-get-mark-alist msgdb-merge)))
+ (setq duplicates (elmo-msgdb-make-index
+ msgdb
+ (elmo-msgdb-get-overview msgdb-merge)
+ (elmo-msgdb-get-mark-alist msgdb-merge)))
+ (elmo-msgdb-set-path
+ msgdb
+ (or (elmo-msgdb-get-path msgdb)
+ (elmo-msgdb-get-path msgdb-merge)))
+ (elmo-folder-set-msgdb-internal folder msgdb)
+ duplicates))
+
(defsubst elmo-msgdb-clear (&optional msgdb)
(if msgdb
(list
(and (setq number (elmo-msgdb-overview-entity-get-number entity))
(elmo-clear-hash-val (format "#%d" number) mhash)))))
-(defun elmo-msgdb-make-index (msgdb &optional overview mark-alist)
+(defun elmo-msgdb-make-index-return (msgdb &optional overview mark-alist)
"Append OVERVIEW and MARK-ALIST to the index of MSGDB.
If OVERVIEW and MARK-ALIST are nil, make index for current MSGDB.
Return the updated INDEX."
(elmo-msgdb-set-index msgdb index)
index)))
+(defun elmo-msgdb-make-index (msgdb &optional overview mark-alist)
+ "Append OVERVIEW and MARK-ALIST to the index of MSGDB.
+If OVERVIEW and MARK-ALIST are nil, make index for current MSGDB.
+Return a list of message numbers which have duplicated message-ids."
+ (when msgdb
+ (let* ((overview (or overview (elmo-msgdb-get-overview msgdb)))
+ (mark-alist (or mark-alist (elmo-msgdb-get-mark-alist msgdb)))
+ (index (elmo-msgdb-get-index msgdb))
+ (ehash (or (car index) ;; append
+ (elmo-make-hash (length overview))))
+ (mhash (or (cdr index) ;; append
+ (elmo-make-hash (length overview))))
+ duplicates)
+ (while overview
+ ;; key is message-id
+ (if (elmo-get-hash-val (caar overview) ehash) ; duplicated.
+ (setq duplicates (cons
+ (elmo-message-entity-number (car overview))
+ duplicates)))
+ (if (caar overview)
+ (elmo-set-hash-val (caar overview) (car overview) ehash))
+ ;; key is number
+ (elmo-set-hash-val
+ (format "#%d"
+ (elmo-message-entity-number (car overview)))
+ (car overview) ehash)
+ (setq overview (cdr overview)))
+ (while mark-alist
+ ;; key is number
+ (elmo-set-hash-val
+ (format "#%d" (car (car mark-alist)))
+ (car mark-alist) mhash)
+ (setq mark-alist (cdr mark-alist)))
+ (setq index (or index (cons ehash mhash)))
+ (elmo-msgdb-set-index msgdb index)
+ duplicates)))
+
(defsubst elmo-folder-get-info (folder &optional hashtb)
(elmo-get-hash-val folder
(or hashtb elmo-folder-info-hashtb)))
(luna-define-generic elmo-folder-process-crosspost (folder)
"Process crosspost for FOLDER.
-If NUMBER-ALIST is set, it is used as number-alist.
Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).")
-(luna-define-generic elmo-folder-append-msgdb (folder append-msgdb)
- "Append APPEND-MSGDB to the current msgdb of the folder.")
-
(luna-define-generic elmo-folder-newsgroups (folder)
"Return list of newsgroup name of FOLDER.")
;; flag-table)
;; "Append ENTITY to the folder.")
-(defun elmo-generic-folder-append-msgdb (folder append-msgdb)
+(defsubst elmo-folder-append-msgdb (folder append-msgdb)
(if append-msgdb
- (let* ((number-alist (elmo-msgdb-get-number-alist append-msgdb))
- (all-alist (copy-sequence (append
- (elmo-msgdb-get-number-alist
- (elmo-folder-msgdb folder))
- number-alist)))
- (cur number-alist)
- pair overview
- to-be-deleted
- mark-alist)
- (elmo-folder-set-msgdb-internal folder
- (elmo-msgdb-append
- (elmo-folder-msgdb folder)
- append-msgdb))
- (while cur
- (setq all-alist (delq (car cur) all-alist))
- ;; same message id exists.
- (if (setq pair (rassoc (cdr (car cur)) all-alist))
- (setq to-be-deleted (nconc to-be-deleted (list (car pair)))))
- (setq cur (cdr cur)))
+ (let ((duplicates (elmo-msgdb-merge folder append-msgdb)))
(cond ((eq (elmo-folder-process-duplicates-internal folder)
'hide)
- ;; Hide duplicates.
- (setq overview (elmo-delete-if
- (lambda (x)
- (memq (elmo-msgdb-overview-entity-get-number
- x)
- to-be-deleted))
- (elmo-msgdb-get-overview append-msgdb)))
+ ;; Let duplicates be a temporary killed message.
+ (elmo-folder-kill-messages folder duplicates)
;; Should be mark as read.
- (elmo-folder-mark-as-read folder to-be-deleted)
- (elmo-msgdb-set-overview append-msgdb overview))
+ (elmo-folder-mark-as-read folder duplicates))
((eq (elmo-folder-process-duplicates-internal folder)
'read)
;; Mark as read duplicates.
- (elmo-folder-mark-as-read folder to-be-deleted))
+ (elmo-folder-mark-as-read folder duplicates))
(t
;; Do nothing.
- (setq to-be-deleted nil)))
- (length to-be-deleted))
+ (setq duplicates nil)))
+ (length duplicates))
0))
-(luna-define-method elmo-folder-append-msgdb ((folder elmo-folder)
- append-msgdb)
- (elmo-generic-folder-append-msgdb folder append-msgdb))
-
(defun elmo-folder-confirm-appends (appends)
(let ((len (length appends))
in)
no-check)
(let ((killed-list (elmo-folder-killed-list-internal folder))
(before-append t)
- number-alist
old-msgdb diff diff-2 delete-list new-list new-msgdb mark
flag-table crossed after-append)
(setq old-msgdb (elmo-folder-msgdb folder))