Fix bug: must read message UIDs _before_ signalling folder event, as
authorChris Hanson <org/chris-hanson/cph>
Thu, 25 May 2000 05:01:40 +0000 (05:01 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 25 May 2000 05:01:40 +0000 (05:01 +0000)
the event handler will usually access the folder, causing extra
unnecessary traffic.

v7/src/imail/imail-imap.scm

index 45067d65a75cb62cf197a228ec5dba90ff24754f..1a5fced5f9a125b84f62ffa57cd2c2dfc42723cc 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.89 2000/05/25 04:53:25 cph Exp $
+;;; $Id: imail-imap.scm,v 1.90 2000/05/25 05:01:40 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
            (not (eq? folder (imap-connection-folder connection))))
        (begin
          (set-imap-folder-messages-synchronized?! folder #f)
-         (set-imap-connection-folder! connection folder)
          (let ((selected? #f))
            (dynamic-wind
-            (lambda () unspecific)
+            (lambda ()
+              (set-imap-connection-folder! connection folder))
             (lambda ()
               (imap:command:select connection
                                    (imap-url-mailbox (folder-url folder)))
                  interrupt-mask
                  ((imail-message-wrapper "Reading message UIDs")
                   (lambda ()
-                    (imap:command:fetch-all (imap-folder-connection folder)
-                                            '(UID))))))
-             (folder-modified! folder 'SET-LENGTH)
+                    (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))
                              (if (> (imap-message-uid m)
                                     (imap-message-uid m*))
                                  (error "Message inserted into folder:" m*))
-                             (loop (fix:+ i 1) i*)))))))))))))
+                             (loop (fix:+ i 1) i*)))))))
+             (folder-modified! folder 'SET-LENGTH)))))))
 \f
 ;;;; Message datatype
 
   (imap:command:single-response imap:response:fetch? connection
                                'UID 'FETCH uid items))
 
-(define (imap:command:fetch-all connection items)
-  (imap:command:multiple-response imap:response:fetch? connection
-                                 'FETCH (cons 'ATOM "1:*") items))
-
 (define (imap:command:fetch-range connection start end items)
   (imap:command:multiple-response
    imap:response:fetch? connection