Several changes that make IMAIL come up much faster with large
authorChris Hanson <org/chris-hanson/cph>
Wed, 17 May 2000 18:40:09 +0000 (18:40 +0000)
committerChris Hanson <org/chris-hanson/cph>
Wed, 17 May 2000 18:40:09 +0000 (18:40 +0000)
folders.  First, we pay attention to the UNSEEN value, and delete
UNSEEN when expunges happen to avoid having an invalid value.  Second,
we don't load headers for all the messages in advance; just their
UIDs, which is very fast.

This allows the mail reader to fetch just the information for the
first unseen message, which happens very quickly on a fast network
connection.

v7/src/imail/imail-imap.scm

index ee9a79f3c42fa019da5e06a188f87c5b5aadbf0c..660346a6a40c231d084a74dce20c74368c9253fd 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.51 2000/05/17 17:30:59 cph Exp $
+;;; $Id: imail-imap.scm,v 1.52 2000/05/17 18:40:09 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
    (lambda ()
      (detach-all-messages! folder)
      (fill-messages-vector! folder 0)
+     (if (imap-folder-uidvalidity folder)
+        (set-imap-folder-unseen! folder #f))
      (set-imap-folder-uidvalidity! folder uidvalidity)
      (folder-modified! folder)))
   (read-message-headers! folder 0))
 
 (define (read-message-headers! folder start)
   (if (imap-folder-uidvalidity folder)
-      ((imail-message-wrapper "Reading message headers")
+      ((imail-message-wrapper "Reading message UIDs")
        (lambda ()
         (imap:command:fetch-range (imap-folder-connection folder)
-                                  start
-                                  (folder-length folder)
-                                  '(UID FLAGS RFC822.SIZE RFC822.HEADER))))))
+                                  start #f '(UID))))))
 \f
 (define (remove-imap-folder-message folder index)
   (without-interrupts
           (vector-set! v i m)))
        (vector-set! v n #f)
        (set-imap-folder-n-messages! folder n)
+       (set-imap-folder-unseen! folder #f)
        (let ((new-length (compute-messages-length v n)))
         (if new-length
             (set-imap-folder-messages! folder
   (guarantee-imap-folder-open folder)
   (vector-ref (imap-folder-messages folder) index))
 
-#|
-;; There's no guarantee that UNSEEN is kept up to date by the server.
-;; So unless we want to manually update it, it's useless.
 (define-method first-unseen-message-index ((folder <imap-folder>))
   (guarantee-imap-folder-open folder)
   (or (imap-folder-unseen folder) 0))
-|#
 
 (define-method expunge-deleted-messages ((folder <imap-folder>))
   (guarantee-imap-folder-open folder)
                                  items))
 
 (define (imap:command:fetch-range connection start end items)
-  (if (< start end)
-      (imap:command:multiple-response imap:response:fetch?
-                                     connection 'FETCH
-                                     (cons 'ATOM
-                                           (string-append
-                                            (number->string (+ start 1))
-                                            ":"
-                                            (number->string end)))
-                                     items)
-      '()))
+  (imap:command:multiple-response imap:response:fetch?
+                                 connection 'FETCH
+                                 (cons 'ATOM
+                                       (string-append
+                                        (number->string (+ start 1))
+                                        ":"
+                                        (if end
+                                            (number->string end)
+                                            "*")))
+                                 items))
 
 (define (imap:command:store-flags connection index flags)
   (imap:command:no-response connection 'STORE (+ index 1) 'FLAGS flags))