From 7d12ee7b1c59fc2a0d92b128b97d8e3e43326c12 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 17 May 2000 18:40:09 +0000 Subject: [PATCH] Several changes that make IMAIL come up much faster with large 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 | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/v7/src/imail/imail-imap.scm b/v7/src/imail/imail-imap.scm index ee9a79f3c..660346a6a 100644 --- a/v7/src/imail/imail-imap.scm +++ b/v7/src/imail/imail-imap.scm @@ -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 ;;; @@ -305,6 +305,8 @@ (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)) @@ -325,12 +327,10 @@ (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)))))) (define (remove-imap-folder-message folder index) (without-interrupts @@ -345,6 +345,7 @@ (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 @@ -654,13 +655,9 @@ (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 )) (guarantee-imap-folder-open folder) (or (imap-folder-unseen folder) 0)) -|# (define-method expunge-deleted-messages ((folder )) (guarantee-imap-folder-open folder) @@ -729,16 +726,16 @@ 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)) -- 2.25.1