From: Brendan Cully Date: Mon, 2 Apr 2007 17:36:20 +0000 (-0700) Subject: Push mbox cache header cache check into imap_mboxcache_get X-Git-Tag: mutt-1-5-15-rel~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cc101727c98367deb847e78c4cf360473284f57;p=mutt Push mbox cache header cache check into imap_mboxcache_get --- diff --git a/ChangeLog b/ChangeLog index 7f81aee9..305e569f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-04-02 10:02 -0700 Brendan Cully (becbad651ecc) + + * imap/imap.c: Cache IMAP access checks + +2007-04-01 23:12 -0700 Brendan Cully (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 (38e896c4c192) * po/zh_TW.po: Updated Taiwanese translation diff --git a/imap/command.c b/imap/command.c index 96aadc24..dbd76ca5 100644 --- a/imap/command.c +++ b/imap/command.c @@ -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) diff --git a/imap/imap.c b/imap/imap.c index b42da8eb..8f702d68 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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)