Don't fetch ranges of the form "N:*" when N is greater than the length
authorChris Hanson <org/chris-hanson/cph>
Mon, 22 Jan 2001 18:38:11 +0000 (18:38 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 22 Jan 2001 18:38:11 +0000 (18:38 +0000)
of the folder.  This causes an error to be signalled on UW IMAP
(although Cyrus accepts this and returns nothing).

v7/src/imail/imail-imap.scm

index 7fc85fd89ec39793ff86f24da69aa79f76700127..18b2b7a42209e19f5e94967c88fe60c7f03ccb8c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.144 2000/08/05 02:00:05 cph Exp $
+;;; $Id: imail-imap.scm,v 1.145 2001/01/22 18:38:11 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
       (vector-set! v index (make-imap-message folder index)))))
 
 (define (read-message-headers! folder start)
-  (if (imap-folder-uidvalidity folder)
+  (if (and (imap-folder-uidvalidity folder)
+          (> (folder-length folder) start))
       ((imail-ui:message-wrapper "Reading message UIDs")
        (lambda ()
         (imap:command:fetch-range (imap-folder-connection folder)
                            #f))
              (fill-messages-vector! folder 0)
              (set-imap-folder-messages-synchronized?! folder #t)
-             (with-interrupt-mask interrupt-mask
-               (lambda (interrupt-mask)
-                 interrupt-mask
-                 ((imail-ui:message-wrapper "Reading message UIDs")
-                  (lambda ()
-                    (imap:command:fetch-range (imap-folder-connection folder)
-                                              0 #f '(UID))))))
+             (if (> count 0)
+                 (with-interrupt-mask interrupt-mask
+                   (lambda (interrupt-mask)
+                     interrupt-mask
+                     ((imail-ui:message-wrapper "Reading message UIDs")
+                      (lambda ()
+                        (imap:command:fetch-range
+                         (imap-folder-connection folder)
+                         0 #f '(UID)))))))
              (let ((v* (imap-folder-messages folder))
                    (n* (imap-folder-n-messages folder)))
                (let loop ((i 0) (i* 0))