Fix APPENDUID handling of uidvalidity.
authorDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 29 Jun 2010 15:45:56 +0000 (16:45 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Tue, 29 Jun 2010 15:45:56 +0000 (16:45 +0100)
We shouldn't be comparing with is->uidvalidity; that's just short-term
storage for use _during_ a SELECT. Compare with ifolder->uidvalidity instead.

Oh, and let's try to make sure that's actually set somewhere...

camel/providers/imapx/camel-imapx-folder.h
camel/providers/imapx/camel-imapx-server.c

index 9bbccea..1ac0b18 100644 (file)
@@ -60,6 +60,7 @@ struct _CamelIMAPXFolder {
        guint32 exists_on_server;
        guint32 unread_on_server;
        guint64 modseq_on_server;
+       guint64 uidvalidity_on_server;
        guint32 uidnext_on_server;
 
        /* hash table of UIDs to ignore as recent when updating folder */
index 9eb6e50..e04a20a 100644 (file)
@@ -1516,6 +1516,7 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
                                ifolder->exists_on_server = sinfo->messages;
                                ifolder->modseq_on_server = sinfo->highestmodseq;
                                ifolder->uidnext_on_server = sinfo->uidnext;
+                               ifolder->uidvalidity_on_server = sinfo->uidvalidity;
                        } else {
                                c(printf("Received STATUS for unknown folder '%s'\n", sinfo->name));
                        }
@@ -2284,6 +2285,7 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
                ifolder->exists_on_server = is->exists;
                ifolder->modseq_on_server = is->highestmodseq;
                ifolder->uidnext_on_server = is->uidnext;
+               ifolder->uidvalidity_on_server = is->uidvalidity;
 #if 0
                /* This must trigger a complete index rebuild! */
                if (is->uidvalidity && is->uidvalidity != ((CamelIMAPXSummary *)is->select_folder->summary)->uidvalidity)
@@ -3126,7 +3128,7 @@ imapx_command_append_message_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
        if (!camel_exception_is_set (ic->ex) && ic->status->result == IMAPX_OK) {
                if (ic->status->condition == IMAPX_APPENDUID) {
                        c(printf("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid));
-                       if (ic->status->u.appenduid.uidvalidity == is->uidvalidity) {
+                       if (ic->status->u.appenduid.uidvalidity == ifolder->uidvalidity_on_server) {
                                CamelFolderChangeInfo *changes;
                                gchar *uid;
 
@@ -3660,9 +3662,9 @@ imapx_job_refresh_info_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
                        }
                } else {
                        if (is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE)
-                               ic = camel_imapx_command_new (is, "STATUS", NULL, "STATUS %f (MESSAGES UNSEEN UIDNEXT HIGHESTMODSEQ)", folder);
+                               ic = camel_imapx_command_new (is, "STATUS", NULL, "STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT HIGHESTMODSEQ)", folder);
                        else
-                               ic = camel_imapx_command_new (is, "STATUS", NULL, "STATUS %f (MESSAGES UNSEEN UIDNEXT)", folder);
+                               ic = camel_imapx_command_new (is, "STATUS", NULL, "STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT)", folder);
                
                        ic->job = job;
                        ic->pri = job->pri;