]> granicus.if.org Git - mutt/commitdiff
Push mbox cache header cache check into imap_mboxcache_get
authorBrendan Cully <brendan@kublai.com>
Mon, 2 Apr 2007 17:36:20 +0000 (10:36 -0700)
committerBrendan Cully <brendan@kublai.com>
Mon, 2 Apr 2007 17:36:20 +0000 (10:36 -0700)
ChangeLog
imap/command.c
imap/imap.c

index 7f81aee917f0650eea6f47e2eea726a293bbce80..305e569fc8a1be93f03c1efdcde6e02f9c5be7e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-04-02 10:02 -0700  Brendan Cully  <brendan@kublai.com>  (becbad651ecc)
+
+       * imap/imap.c: Cache IMAP access checks
+
+2007-04-01 23:12 -0700  Brendan Cully  <brendan@kublai.com>  (4f598543d7a5)
+
+       * imap/imap.c, imap/message.c: Adjust context->size on IMAP load
+       and expunge (closes #2749)
+
 2007-04-01 20:00 -0700  Ambrose Li  <a.c.li@ieee.org>  (38e896c4c192)
 
        * po/zh_TW.po: Updated Taiwanese translation
index 96aadc24d7b962bf1ea0feb348c7427ce1f49440..dbd76ca5c56084bfd7d16b5a07f7af8c135686c5 100644 (file)
@@ -821,11 +821,6 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s)
   int count;
   IMAP_STATUS *status, sb;
   int olduv, oldun;
-#if USE_HCACHE
-  header_cache_t *hc = NULL;
-  unsigned int *uidvalidity = NULL;
-  unsigned int *uidnext = NULL;
-#endif
 
   mailbox = imap_next_word (s);
   s = imap_next_word (mailbox);
@@ -911,24 +906,6 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s)
         dprint (3, (debugfile, "Found %s in buffy list (OV: %d ON: %d U: %d)\n",
                     mailbox, olduv, oldun, status->unseen));
         
-#if USE_HCACHE
-       /* fetch seen info from hcache if we haven't seen it yet this session */
-       if (!olduv && !oldun)
-       {
-         hc = mutt_hcache_open (HeaderCache, inc->path);
-         if (hc)
-         {
-           uidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen);
-           uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen);
-           olduv = uidvalidity ? *uidvalidity : 0;
-           oldun = uidnext ? *uidnext : 0;
-           FREE (&uidvalidity);
-           FREE (&uidnext);
-           mutt_hcache_close (hc);
-           dprint (3, (debugfile, "hcache olduv %d, oldun %d\n", olduv, oldun));
-         }
-       }
-#endif
         if (olduv && olduv == status->uidvalidity)
         {
           if (oldun < status->uidnext)
index b42da8eb590065652276e4fa6e4173a141532f4a..8f702d68f01cc4fa975427f5f4b0177acc8a8164 100644 (file)
@@ -1581,6 +1581,15 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox)
 {
   LIST* cur;
   IMAP_STATUS* status;
+  IMAP_STATUS scache;
+#ifdef USE_HCACHE
+  header_cache_t *hc = NULL;
+  ciss_url_t url;
+  char urlstr[LONG_STRING];
+  unsigned int *uidvalidity = NULL;
+  unsigned int *uidnext = NULL;
+  char* path;
+#endif
   
   for (cur = idata->mboxcache; cur; cur = cur->next)
   {
@@ -1589,8 +1598,40 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox)
     if (!imap_mxcmp (mbox, status->name))
       return status;
   }
-  
-  return NULL;
+  status = NULL;
+
+#ifdef USE_HCACHE
+  path = safe_strdup (idata->ctx->path);
+  url_parse_ciss (&url, path);
+  url.path = (char*)mbox;
+  url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0);
+  FREE (&path);
+  hc = mutt_hcache_open (HeaderCache, urlstr);
+  if (hc)
+  {
+    uidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen);
+    uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen);
+    if (uidvalidity)
+    {
+      /* lame */
+      memset (&scache, 0, sizeof (scache));
+      scache.name = (char*)mbox;
+      idata->mboxcache = mutt_add_list_n (idata->mboxcache, &scache,
+                                          sizeof (scache));
+      status = imap_mboxcache_get (idata, mbox);
+      status->name = safe_strdup (mbox);
+      status->uidvalidity = *uidvalidity;
+      status->uidnext = uidnext ? *uidnext: 0;
+      dprint (3, (debugfile, "mboxcache: hcache uidvalidity %d, uidnext %d\n",
+                  status->uidvalidity, status->uidnext));
+    }
+    FREE (&uidvalidity);
+    FREE (&uidnext);
+    mutt_hcache_close (hc);
+  }
+#endif
+
+  return status;
 }
 
 void imap_mboxcache_free (IMAP_DATA* idata)