]> granicus.if.org Git - mutt/commitdiff
IMAP message cache fixes: embed UIDVALIDITY in the cache file name, only
authorBrendan Cully <brendan@kublai.com>
Fri, 23 Dec 2005 17:53:23 +0000 (17:53 +0000)
committerBrendan Cully <brendan@kublai.com>
Fri, 23 Dec 2005 17:53:23 +0000 (17:53 +0000)
delete deleted messages at sync time. Also use an alias to make the sync
code clearer.

imap/imap.c
imap/message.c

index e122224415a04e7dcc26b62a13eab366fa6caf74..4e13caed83817ee08339d2a77d657421cd807d66 100644 (file)
@@ -1075,6 +1075,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
   IMAP_DATA* idata;
   CONTEXT* appendctx = NULL;
   BUFFER cmd;
+  HEADER* h;
   int deleted;
   int n;
   int rc;
@@ -1126,7 +1127,6 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
     }
   }
 
-
 #if USE_HCACHE
   if (expunge && ctx->closing)
     hc = mutt_hcache_open (HeaderCache, idata->ctx->path);
@@ -1135,21 +1135,24 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
   /* save messages with real (non-flag) changes */
   for (n = 0; n < ctx->msgcount; n++)
   {
-    imap_cache_del (idata, ctx->hdrs[n]);
+    h = ctx->hdrs[n];
+
+    if (h->deleted)
+      imap_cache_del (idata, h);
 #if USE_HCACHE
-    if (hc && ctx->hdrs[n]->deleted)
+    if (hc && h->deleted)
     {
-      sprintf (uidbuf, "/%u", HEADER_DATA(ctx->hdrs[n])->uid);
+      sprintf (uidbuf, "/%u", HEADER_DATA(h)->uid);
       mutt_hcache_delete (hc, uidbuf, imap_hcache_keylen);
     }
 #endif
-    if (ctx->hdrs[n]->active && ctx->hdrs[n]->changed)
+    if (h->active && h->changed)
     {
       /* if the message has been rethreaded or attachments have been deleted
        * we delete the message and reupload it.
        * This works better if we're expunging, of course. */
-      if ((ctx->hdrs[n]->env && (ctx->hdrs[n]->env->refs_changed || ctx->hdrs[n]->env->irt_changed)) ||
-         ctx->hdrs[n]->attach_del)
+      if ((h->env && (h->env->refs_changed || h->env->irt_changed)) ||
+         h->attach_del)
       {
         mutt_message (_("Saving changed messages... [%d/%d]"), n+1,
                       ctx->msgcount);
@@ -1160,7 +1163,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
          dprint (1, (debugfile, "imap_sync_mailbox: Error opening mailbox in append mode\n"));
        }
        else
-         _mutt_save_message (ctx->hdrs[n], appendctx, 1, 0, 0);
+         _mutt_save_message (h, appendctx, 1, 0, 0);
       }
     }
   }
index 884ebe1e16bd6db0a901ff9840b5f496b8ab0493..a43ad5b29c96c072911193b947dba3c930c6a622 100644 (file)
@@ -879,7 +879,8 @@ static int msg_cache_path (IMAP_DATA* idata, HEADER* h, char* buf, size_t len)
   *s = '\0';
 
   slen = mutt_strlen (buf);
-  snprintf (buf + slen, len - slen, "/%u", HEADER_DATA(h)->uid);
+  snprintf (buf + slen, len - slen, "/%u-%u", idata->uid_validity,
+            HEADER_DATA(h)->uid);
 
   return 0;
 }