]> granicus.if.org Git - mutt/commitdiff
POP: Name hcache the way IMAP does.
authorRocco Rutte <pdmef@gmx.net>
Tue, 11 Dec 2007 13:58:31 +0000 (14:58 +0100)
committerRocco Rutte <pdmef@gmx.net>
Tue, 11 Dec 2007 13:58:31 +0000 (14:58 +0100)
Place the file under $header_cache/<url>/mutt.hcache. For now ignore
that this may break if hcache == bcache and a message's uid is
"mutt.hcache" (extremely unlikely) in which case the user will loose
only the hcache file.

ChangeLog
pop.c

index 3c019e543a910701902556c1bda0cff9d889f417..0f92f148b2af7ba623f6eb50cd0e438e799c62e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-12-11 14:50 +0100  Rocco Rutte  <pdmef@gmx.net>  (f19984dcfacb)
+
+       * pop.c: POP: Respect $message_cache_clean
+
+2007-12-11 14:49 +0100  Rocco Rutte  <pdmef@gmx.net>  (2707a97e0deb)
+
+       * doc/manual.xml.head: Manual: mention $time_inc in tuning chapter
+
+2007-12-11 13:12 +0100  Rocco Rutte  <pdmef@gmx.net>  (9709d244c64b)
+
+       * ChangeLog, enter.c, history.h: Maintain different history lists for
+       files and mailboxes. Closes #2999.
+
 2007-12-11 13:08 +0100  Rocco Rutte  <pdmef@gmx.net>  (35d778452444)
 
        * history.c: Do not trust history file and mutt code about history
diff --git a/pop.c b/pop.c
index 273bbf5b7267a604da9643e2ca028e4545b727c1..255369c280cead714c5fe8aa84c906ab73ba2f24 100644 (file)
--- a/pop.c
+++ b/pop.c
 #include <string.h>
 #include <unistd.h>
 
+#ifdef USE_HCACHE
+#define HC_FNAME       "mutt"          /* filename for hcache as POP lacks paths */
+#define HC_FEXT                "hcache"        /* extension for hcache as POP lacks paths */
+#endif
+
 /* write line to file */
 static int fetch_message (char *line, void *file)
 {
@@ -173,6 +178,12 @@ static int msg_cache_check (const char *id, body_cache_t *bcache, void *data)
   if (!(pop_data = (POP_DATA *)ctx->data))
     return -1;
 
+#ifdef USE_HCACHE
+  /* keep hcache file if hcache == bcache */
+  if (strcmp (HC_FNAME "." HC_FEXT, id) == 0)
+    return 0;
+#endif
+
   for (i = 0; i < ctx->msgcount; i++)
     /* if the id we get is known for a header: done (i.e. keep in cache) */
     if (ctx->hdrs[i]->data && mutt_strcmp (ctx->hdrs[i]->data, id) == 0)
@@ -184,6 +195,27 @@ static int msg_cache_check (const char *id, body_cache_t *bcache, void *data)
   return mutt_bcache_del (bcache, id);
 }
 
+#ifdef USE_HCACHE
+static int pop_hcache_namer (const char *path, char *dest, size_t destlen)
+{
+  return snprintf (dest, destlen, "%s." HC_FEXT, path);
+}
+
+static header_cache_t *pop_hcache_open (POP_DATA *pop_data, const char *path)
+{
+  ciss_url_t url;
+  char p[LONG_STRING];
+
+  if (!pop_data || !pop_data->conn)
+    return mutt_hcache_open (HeaderCache, path, NULL);
+
+  mutt_account_tourl (&pop_data->conn->account, &url);
+  url.path = HC_FNAME;
+  url_ciss_tostring (&url, p, sizeof (p), U_PATH);
+  return mutt_hcache_open (HeaderCache, p, pop_hcache_namer);
+}
+#endif
+
 /*
  * Read headers
  * returns:
@@ -203,7 +235,7 @@ static int pop_fetch_headers (CONTEXT *ctx)
   header_cache_t *hc = NULL;
   void *data;
 
-  hc = mutt_hcache_open (HeaderCache, ctx->path, NULL);
+  hc = pop_hcache_open (pop_data, ctx->path);
 #endif
 
   time (&pop_data->check_time);
@@ -614,7 +646,7 @@ int pop_sync_mailbox (CONTEXT *ctx, int *index_hint)
                        M_PROGRESS_MSG, WriteInc, ctx->deleted);
 
 #if USE_HCACHE
-    hc = mutt_hcache_open (HeaderCache, ctx->path, NULL);
+    hc = pop_hcache_open (pop_data, ctx->path);
 #endif
 
     for (i = 0, j = 0, ret = 0; ret == 0 && i < ctx->msgcount; i++)