Here is a quick and dirty patch for flushing the seen state whenever it changes, relative to 2.1.11. I have tested it on my production system and it seems fine, but use at your own risk. The quick and dirty part is that the interface to index_check doesn't provide a way to pass the quiet flag to index_checkseen, so that means the client may see an extra untagged response giving the flags (and in fact in the case of a fetch n flags, multiple copies). However, my reading of the protocol is that the client has to be prepared for these anyway, so I don't think it will be a problem. If anyone tries it and notices any problems with any clients, please let me know. The right way to fix it is to change the interface to index_check to include a quiet parameter, pass that parameter on to index_checkseen, and change all the calls to index_check to pass it appropriately.

--
John A. Tamplin
Unix Systems Administrator

--- /src.new/stock/cyrus-imapd-2.1.11/imap/imapd.c      Mon Nov 18 10:50:15 2002
+++ imapd.c     Mon Dec 23 19:15:46 2002
@@ -2948,8 +2948,8 @@
 
     if (usinguid) {
        fetchitems |= FETCH_UID;
-       index_check(imapd_mailbox, 1, 0);
     }
+    index_check(imapd_mailbox, usinguid, 1);
 
     fetchargs.fetchitems = fetchitems;
     index_fetch(imapd_mailbox, sequence, usinguid, &fetchargs,
@@ -2958,6 +2958,9 @@
     if (fetchedsomething || usinguid) {
        prot_printf(imapd_out, "%s OK %s\r\n", tag,
                    error_message(IMAP_OK_COMPLETED));
+       if(fetchargs.fetchitems & FETCH_SETSEEN) {
+               index_check(imapd_mailbox,usinguid,1);
+       }
     } else {
        /* normal FETCH, nothing came back */
        prot_printf(imapd_out, "%s NO %s\r\n", tag,
@@ -3065,7 +3068,8 @@
 
     index_fetch(imapd_mailbox, msgno, 0, &fetchargs, &fetchedsomething);
 
-    index_check(imapd_mailbox, 0, 0);
+    index_check(imapd_mailbox, 0,
+       fetchedsomething && (fetchargs.fetchitems & FETCH_SETSEEN));
 
     if (fetchedsomething) {
        prot_printf(imapd_out, "%s OK %s\r\n", tag,
@@ -3201,7 +3205,9 @@
     r = index_store(imapd_mailbox, sequence, usinguid, &storeargs,
                    flag, nflags);
 
-    if (usinguid) {
+    if(storeargs.seen || storeargs.operation==STORE_REPLACE) {
+       index_check(imapd_mailbox, usinguid, 1);
+    } else if (usinguid) {
        index_check(imapd_mailbox, 1, 0);
     }
 


Reply via email to