Work around broken IMAP servers that give bogus responses to FETCH.
authorTaylor R Campbell <campbell@mumble.net>
Wed, 12 Dec 2012 06:10:18 +0000 (06:10 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 12 Dec 2012 06:10:18 +0000 (06:10 +0000)
src/imail/imail-imap.scm

index a403343c31b98422f9a445eb60066a549c395f76..8b3593a2cfae1f798ec1f6055258217048475df6 100644 (file)
@@ -1336,10 +1336,20 @@ USA.
               (lambda (keywords messages)
                 (imap:command:fetch-set/for-each
                  (lambda (response)
-                   (if (zero? (remainder count 10))
-                       (imail-ui:progress-meter count total-count))
-                   (set! count (+ count 1))
-                   (cache-preload-response folder keywords response))
+                    ;; Some IMAP servers (I'm looking at you, Dovecot)
+                    ;; return untagged non-FETCH responses here, namely
+                    ;; untagged OK messages, perhaps to indicate some
+                    ;; kind of progress.
+                   (cond ((imap:response:fetch? response)
+                           (if (zero? (remainder count 10))
+                               (imail-ui:progress-meter count total-count))
+                           (set! count (+ count 1))
+                           (cache-preload-response folder keywords response))
+                          ((imap:response:status-response? response)
+                           (imail-ui:message
+                            (string-append
+                             "Server message: "
+                             (imap:response:response-text-string response))))))
                  connection
                  (message-list->set (reverse! messages))
                  keywords)))))))))