]> granicus.if.org Git - neomutt/commitdiff
Add imap_hcache_del; minor cleanups
authorBrendan Cully <brendan@kublai.com>
Tue, 10 Apr 2007 22:32:08 +0000 (15:32 -0700)
committerBrendan Cully <brendan@kublai.com>
Tue, 10 Apr 2007 22:32:08 +0000 (15:32 -0700)
imap/command.c
imap/imap.c
imap/imap_private.h
imap/util.c

index 329155208cc5e3544dee8f72d8e7b89ac1ad1e29..c67066e0d4d3561ae60463153037be3a6dc90c8e 100644 (file)
@@ -30,9 +30,6 @@
 #include "message.h"
 #include "mx.h"
 #include "buffy.h"
-#if USE_HCACHE
-#include "hcache.h"
-#endif
 
 #include <ctype.h>
 #include <stdlib.h>
index c68f361ebfbfb2a3ccc9b7c5fb33d2c752b808f0..aeec066d42a297f1bebbef0833dd519bba458361 100644 (file)
@@ -248,10 +248,6 @@ void imap_expunge_mailbox (IMAP_DATA* idata)
   HEADER* h;
   int i, cacheno;
 
-#if USE_HCACHE
-  char uidbuf[32];
-#endif
-
   for (i = 0; i < idata->ctx->msgcount; i++)
   {
     h = idata->ctx->hdrs[i];
@@ -265,11 +261,7 @@ void imap_expunge_mailbox (IMAP_DATA* idata)
 
       imap_cache_del (idata, h);
 #if USE_HCACHE
-      if (idata->hcache)
-      {
-        sprintf (uidbuf, "/%u", HEADER_DATA(h)->uid);
-        mutt_hcache_delete (idata->hcache, uidbuf, imap_hcache_keylen);
-      }
+      imap_hcache_del (idata, HEADER_DATA(h)->uid);
 #endif
 
       /* free cached body from disk, if necessary */
@@ -1103,9 +1095,6 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
   int deleted;
   int n;
   int rc;
-#if USE_HCACHE
-  char uidbuf[32];
-#endif
   
   idata = (IMAP_DATA*) ctx->data;
 
@@ -1156,14 +1145,13 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint)
     h = ctx->hdrs[n];
 
     if (h->deleted)
+    {
       imap_cache_del (idata, h);
 #if USE_HCACHE
-    if (idata->hcache && h->deleted)
-    {
-      sprintf (uidbuf, "/%u", HEADER_DATA(h)->uid);
-      mutt_hcache_delete (idata->hcache, uidbuf, imap_hcache_keylen);
-    }
+      imap_hcache_del (idata, HEADER_DATA(h)->uid);
 #endif
+    }
+    
     if (h->active && h->changed)
     {
       /* if the message has been rethreaded or attachments have been deleted
index efa6ea77caafa9908f55614575dce6a750c6a60a..b28e5ae30f122715c8bb659257e175f8558afffe 100644 (file)
@@ -262,6 +262,7 @@ int imap_cache_del (IMAP_DATA* idata, HEADER* h);
 header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path);
 HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid);
 int imap_hcache_put (IMAP_DATA* idata, HEADER* h);
+int imap_hcache_del (IMAP_DATA* idata, unsigned int uid);
 #endif
 
 int imap_continue (const char* msg, const char* resp);
index e55c7bb3709bbca1b37e59ad2332d83bea42ce93..c62414685006cd47d50169eadd3630e2caf53ef4 100644 (file)
@@ -94,7 +94,10 @@ HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid)
   unsigned int* uv;
   HEADER* h = NULL;
 
-  sprintf(key, "/%u", uid);
+  if (!idata->hcache)
+    return NULL;
+
+  sprintf (key, "/%u", uid);
   uv = (unsigned int*)mutt_hcache_fetch (idata->hcache, key,
                                          imap_hcache_keylen);
   if (uv)
@@ -111,10 +114,24 @@ int imap_hcache_put (IMAP_DATA* idata, HEADER* h)
 {
   char key[16];
 
-  sprintf(key, "/%u", HEADER_DATA (h)->uid);
+  if (!idata->hcache)
+    return -1;
+
+  sprintf (key, "/%u", HEADER_DATA (h)->uid);
   return mutt_hcache_store (idata->hcache, key, h, idata->uid_validity,
                             imap_hcache_keylen);
 }
+
+int imap_hcache_del (IMAP_DATA* idata, unsigned int uid)
+{
+  char key[16];
+
+  if (!idata->hcache)
+    return -1;
+
+  sprintf (key, "/%u", uid);
+  return mutt_hcache_delete (idata->hcache, key, imap_hcache_keylen);
+}
 #endif
 
 /* imap_parse_path: given an IMAP mailbox name, return host, port