Fix merge updates.
authorvitaly <v.mayatskih@gmail.com>
Sun, 8 Feb 2009 13:51:26 +0000 (8 14:51 +0100)
committervitaly <v.mayatskih@gmail.com>
Sun, 8 Feb 2009 13:51:26 +0000 (8 14:51 +0100)
Do full update of messages list in case of merged list size differs
from server's one. This eliminates situation when another clients
delete old messages (move to spam, etc).

elmo/elmo-imap4.el

index 76162af..d1b6c21 100644 (file)
@@ -1981,26 +1981,37 @@ Return nil if no complete line has arrived."
          (elmo-msgdb-killed-list-length killed))
        (elmo-imap4-response-value status 'messages)))))
 
-(luna-define-method elmo-folder-list-messages-plugged ((folder
-                                                       elmo-imap4-folder)
-                                                      &optional
-                                                      enable-killed)
-  (let ((old (elmo-msgdb-list-messages (elmo-folder-msgdb folder)))
-       (new (elmo-imap4-list
-             folder
-             (concat
-              (let ((killed
-                     (elmo-folder-killed-list-internal
-                      folder)))
-                (if (and killed
-                         (eq (length killed) 1)
-                         (consp (car killed))
-                         (eq (car (car killed)) 1))
+(defun elmo-imap4-folder-list-range (folder min max)
+  (elmo-imap4-list
+   folder
+   (concat
+    (let ((killed
+          (elmo-folder-killed-list-internal
+           folder)))
+      (if (and killed
+              (eq (length killed) 1)
+              (consp (car killed))
+              (eq (car (car killed)) 1))
 ;; What about elmo-imap4-use-uid?
-                    (format "uid %d:*" (cdr (car killed)))
-                  (format "uid %d:*" (1+ (elmo-folder-get-info-max folder)))))
-              " undeleted"))))
-    (union old new)))
+         (format "uid %d:%s" (cdr (car killed)) max)
+       (format "uid %s:%s" min max)))
+    " undeleted")))
+
+(luna-define-method elmo-folder-list-messages-plugged ((folder
+                                                        elmo-imap4-folder)
+                                                       &optional
+                                                       enable-killed)
+
+  (let* ((old (elmo-msgdb-list-messages (elmo-folder-msgdb folder)))
+         (new (elmo-imap4-folder-list-range folder
+               (1+ (elmo-folder-get-info-max folder)) "*"))
+         (united-old-new (elmo-union old new)))
+    (if (= (length united-old-new) (elmo-folder-get-info-length folder))
+        united-old-new
+      (elmo-union new
+                 (elmo-imap4-folder-list-range
+                  folder
+                  1 (1+ (elmo-folder-get-info-max folder)))))))
 
 (luna-define-method elmo-folder-list-flagged-plugged
   ((folder elmo-imap4-folder) flag)