#include "message.h"
#include "mx.h"
#include "buffy.h"
-#if USE_HCACHE
-#include "hcache.h"
-#endif
#include <ctype.h>
#include <stdlib.h>
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];
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 */
int deleted;
int n;
int rc;
-#if USE_HCACHE
- char uidbuf[32];
-#endif
idata = (IMAP_DATA*) ctx->data;
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
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);
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)
{
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