summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Elkins <me@sigpipe.org>2013-01-17 02:43:41 +0000
committerMichael Elkins <me@sigpipe.org>2013-01-17 02:43:41 +0000
commit9736319d31cd9ee8d9fcb85199d80a5620d5161d (patch)
treeb20768c6a4b7d876c15343ebba6d7ed34f9b6aa3
parent5e0b295a66b7d5c414847fbd07c345da19cc2fe2 (diff)
use a separate flag for mutt_hcache_store() to signal that the gettimeofday() value should be substituted, so that a 0 uidvalidity can be used by the imap driver.
closes #3501
-rw-r--r--hcache.c22
-rw-r--r--hcache.h7
-rw-r--r--imap/util.c2
-rw-r--r--mh.c8
-rw-r--r--pop.c4
5 files changed, 28 insertions, 15 deletions
diff --git a/hcache.c b/hcache.c
index f6e091b0..af17932d 100644
--- a/hcache.c
+++ b/hcache.c
@@ -588,10 +588,11 @@ mutt_hcache_per_folder(const char *path, const char *folder,
}
/* This function transforms a header into a char so that it is useable by
- * db_store */
+ * db_store.
+ */
static void *
mutt_hcache_dump(header_cache_t *h, HEADER * header, int *off,
- unsigned int uidvalidity)
+ unsigned int uidvalidity, mutt_hcache_store_flags_t flags)
{
unsigned char *d = NULL;
HEADER nh;
@@ -600,14 +601,14 @@ mutt_hcache_dump(header_cache_t *h, HEADER * header, int *off,
*off = 0;
d = lazy_malloc(sizeof (validate));
- if (uidvalidity)
- memcpy(d, &uidvalidity, sizeof (uidvalidity));
- else
+ if (flags & M_GENERATE_UIDVALIDITY)
{
struct timeval now;
gettimeofday(&now, NULL);
memcpy(d, &now, sizeof (struct timeval));
}
+ else
+ memcpy(d, &uidvalidity, sizeof (uidvalidity));
*off += sizeof (validate);
d = dump_int(h->crc, d, off);
@@ -759,10 +760,17 @@ mutt_hcache_fetch_raw (header_cache_t *h, const char *filename,
#endif
}
+/*
+ * flags
+ *
+ * M_GENERATE_UIDVALIDITY
+ * ignore uidvalidity param and store gettimeofday() as the value
+ */
int
mutt_hcache_store(header_cache_t *h, const char *filename, HEADER * header,
unsigned int uidvalidity,
- size_t(*keylen) (const char *fn))
+ size_t(*keylen) (const char *fn),
+ mutt_hcache_store_flags_t flags)
{
char* data;
int dlen;
@@ -771,7 +779,7 @@ mutt_hcache_store(header_cache_t *h, const char *filename, HEADER * header,
if (!h)
return -1;
- data = mutt_hcache_dump(h, header, &dlen, uidvalidity);
+ data = mutt_hcache_dump(h, header, &dlen, uidvalidity, flags);
ret = mutt_hcache_store_raw (h, filename, data, dlen, keylen);
FREE(&data);
diff --git a/hcache.h b/hcache.h
index aab263bc..62eaa18b 100644
--- a/hcache.h
+++ b/hcache.h
@@ -33,9 +33,14 @@ HEADER *mutt_hcache_restore(const unsigned char *d, HEADER **oh);
void *mutt_hcache_fetch(header_cache_t *h, const char *filename, size_t (*keylen)(const char *fn));
void *mutt_hcache_fetch_raw (header_cache_t *h, const char *filename,
size_t (*keylen)(const char *fn));
+
+typedef enum {
+ M_GENERATE_UIDVALIDITY = 1 /* use gettimeofday() as value */
+} mutt_hcache_store_flags_t;
+
/* uidvalidity is an IMAP-specific unsigned 32 bit number */
int mutt_hcache_store(header_cache_t *h, const char *filename, HEADER *header,
- unsigned int uidvalidity, size_t (*keylen)(const char *fn));
+ unsigned int uidvalidity, size_t (*keylen)(const char *fn), mutt_hcache_store_flags_t flags_t);
int mutt_hcache_store_raw (header_cache_t *h, const char* filename, void* data,
size_t dlen, size_t(*keylen) (const char* fn));
int mutt_hcache_delete(header_cache_t *h, const char *filename, size_t (*keylen)(const char *fn));
diff --git a/imap/util.c b/imap/util.c
index 7515088b..657a2fb9 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -145,7 +145,7 @@ int imap_hcache_put (IMAP_DATA* idata, HEADER* h)
sprintf (key, "/%u", HEADER_DATA (h)->uid);
return mutt_hcache_store (idata->hcache, key, h, idata->uid_validity,
- imap_hcache_keylen);
+ imap_hcache_keylen, 0);
}
int imap_hcache_del (IMAP_DATA* idata, unsigned int uid)
diff --git a/mh.c b/mh.c
index 21f516bb..7a8d7756 100644
--- a/mh.c
+++ b/mh.c
@@ -1080,9 +1080,9 @@ static void maildir_delayed_parsing (CONTEXT * ctx, struct maildir **md,
p->header_parsed = 1;
#if USE_HCACHE
if (ctx->magic == M_MH)
- mutt_hcache_store (hc, p->h->path, p->h, 0, strlen);
+ mutt_hcache_store (hc, p->h->path, p->h, 0, strlen, M_GENERATE_UIDVALIDITY);
else
- mutt_hcache_store (hc, p->h->path + 3, p->h, 0, &maildir_hcache_keylen);
+ mutt_hcache_store (hc, p->h->path + 3, p->h, 0, &maildir_hcache_keylen, M_GENERATE_UIDVALIDITY);
#endif
} else
mutt_free_header (&p->h);
@@ -1714,9 +1714,9 @@ int mh_sync_mailbox (CONTEXT * ctx, int *index_hint)
{
if (ctx->magic == M_MAILDIR)
mutt_hcache_store (hc, ctx->hdrs[i]->path + 3, ctx->hdrs[i],
- 0, &maildir_hcache_keylen);
+ 0, &maildir_hcache_keylen, M_GENERATE_UIDVALIDITY);
else if (ctx->magic == M_MH)
- mutt_hcache_store (hc, ctx->hdrs[i]->path, ctx->hdrs[i], 0, strlen);
+ mutt_hcache_store (hc, ctx->hdrs[i]->path, ctx->hdrs[i], 0, strlen, M_GENERATE_UIDVALIDITY);
}
#endif
diff --git a/pop.c b/pop.c
index 9fa65543..85c34d1d 100644
--- a/pop.c
+++ b/pop.c
@@ -324,7 +324,7 @@ static int pop_fetch_headers (CONTEXT *ctx)
#if USE_HCACHE
else
{
- mutt_hcache_store (hc, ctx->hdrs[i]->data, ctx->hdrs[i], 0, strlen);
+ mutt_hcache_store (hc, ctx->hdrs[i]->data, ctx->hdrs[i], 0, strlen, M_GENERATE_UIDVALIDITY);
}
FREE(&data);
@@ -693,7 +693,7 @@ int pop_sync_mailbox (CONTEXT *ctx, int *index_hint)
#if USE_HCACHE
if (ctx->hdrs[i]->changed)
{
- mutt_hcache_store (hc, ctx->hdrs[i]->data, ctx->hdrs[i], 0, strlen);
+ mutt_hcache_store (hc, ctx->hdrs[i]->data, ctx->hdrs[i], 0, strlen, M_GENERATE_UIDVALIDITY);
}
#endif