Change URL-EXISTS? to use the LIST command, and to filter out NOSELECT
authorChris Hanson <org/chris-hanson/cph>
Mon, 7 May 2001 18:01:05 +0000 (18:01 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 7 May 2001 18:01:05 +0000 (18:01 +0000)
mailboxes.

v7/src/imail/imail-imap.scm

index b02df7d9db207e620aa999a404b5a15e028f2d45..124192bf5056aa5369366fc8d97816e7d659ac29 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.147 2001/01/24 22:51:35 cph Exp $
+;;; $Id: imail-imap.scm,v 1.148 2001/05/07 18:01:05 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
 ;;;
@@ -16,7 +16,8 @@
 ;;;
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with this program; if not, write to the Free Software
-;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;;; 02111-1307, USA.
 
 ;;;; IMAIL mail reader: IMAP back end
 
        (= (imap-url-port url1) (imap-url-port url2))))
 \f
 (define-method url-exists? ((url <imap-url>))
-  (not
-   (condition?
-    (ignore-errors
-     (lambda ()
-       (with-open-imap-connection url
-        (lambda (connection)
-          (imap:command:status connection
-                               (imap-url-server-mailbox url)
-                               '(MESSAGES))))
-       #t)))))
+  (let ((responses
+        (with-open-imap-connection url
+          (lambda (connection)
+            (imap:command:list connection
+                               ""
+                               (imap-url-server-mailbox url))))))
+    (and (pair? responses)
+        (null? (cdr responses))
+        (not (memq '\NOSELECT (imap:response:list-flags (car responses)))))))
 
 (define-method url-pass-phrase-key ((url <imap-url>))
   (make-url-string (url-protocol url) (make-imap-url-string url #f)))