Work around a buggy IMAP server that returns bogus UNSEEN counts.
authorTaylor R Campbell <campbell@mumble.net>
Sun, 27 Jun 2010 22:18:10 +0000 (22:18 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sun, 27 Jun 2010 22:18:10 +0000 (22:18 +0000)
src/imail/imail-imap.scm

index f88b8098196131e771f51eba14cad8ef4c2c831d..333b1d2c7cd55b01c020ae063b7c3f972fb3c2f4 100644 (file)
@@ -2298,7 +2298,11 @@ USA.
   (vector-ref (imap-folder-messages folder) index))
 
 (define-method first-unseen-message-index ((folder <imap-folder>))
-  (or (imap-folder-unseen folder) 0))
+  (or (let ((unseen (imap-folder-unseen folder)))
+       (and unseen
+            (< unseen (folder-length folder))
+            unseen))
+      0))
 
 (define-method expunge-deleted-messages ((folder <imap-folder>))
   (imap:command:expunge (guarantee-imap-folder-open folder)))