]> granicus.if.org Git - neomutt/commitdiff
imap: remove ImapCache
authorMehdi Abaakouk <sileht@sileht.net>
Fri, 21 Dec 2018 18:28:19 +0000 (19:28 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 21 Dec 2018 20:00:45 +0000 (20:00 +0000)
The ImapCache is useless since it's used only when we fail bcache.
And this is not really expected.

imap/imap.c
imap/imap_private.h
imap/message.c
imap/util.c

index 292f12bfe6915bcd480f9f41a1003ce8f6f6eb87..956ce7bd6a2e2e0b0b0fb63de1bd9b8cb34c75ca 100644 (file)
@@ -784,7 +784,6 @@ void imap_expunge_mailbox(struct Mailbox *m)
     return;
 
   struct Email *e = NULL;
-  int cacheno;
   short old_sort;
 
 #ifdef USE_HCACHE
@@ -811,15 +810,6 @@ void imap_expunge_mailbox(struct Mailbox *m)
       imap_hcache_del(mdata, imap_edata_get(e)->uid);
 #endif
 
-      /* free cached body from disk, if necessary */
-      cacheno = imap_edata_get(e)->uid % IMAP_CACHE_LEN;
-      if (mdata->cache[cacheno].uid == imap_edata_get(e)->uid &&
-          mdata->cache[cacheno].path)
-      {
-        unlink(mdata->cache[cacheno].path);
-        FREE(&mdata->cache[cacheno].path);
-      }
-
       mutt_hash_int_delete(mdata->uid_hash, imap_edata_get(e)->uid, e);
 
       imap_edata_free((void **) &e->edata);
index 599f962ca3096c65476e6581a41d9bda36865c13..6461034407b2b3249c2733d27bd1fa1af4b247c2 100644 (file)
@@ -142,15 +142,6 @@ enum ImapCaps
   IMAP_CAP_MAX,
 };
 
-/**
- * struct ImapCache - IMAP-specific message cache
- */
-struct ImapCache
-{
-  unsigned int uid;
-  char *path;
-};
-
 /**
  * struct ImapList - Items in an IMAP browser
  */
@@ -242,7 +233,6 @@ struct ImapMboxData
   unsigned int unseen;
 
   // Cached data used only when the mailbox is opened
-  struct ImapCache cache[IMAP_CACHE_LEN];
   struct Hash *uid_hash;
   struct Email **msn_index;   /**< look up headers by (MSN-1) */
   size_t msn_index_size;       /**< allocation size */
index 03b247ce850a0f8d961ca134b2b819f01f22413a..e591ecdfeff626ae74faee431caa21652426f9d3 100644 (file)
@@ -1850,13 +1850,10 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
 
   struct Envelope *newenv = NULL;
   char buf[LONG_STRING];
-  char path[PATH_MAX];
   char *pc = NULL;
   unsigned int bytes;
   struct Progress progressbar;
   unsigned int uid;
-  int cacheno;
-  struct ImapCache *cache = NULL;
   bool retried = false;
   bool read;
   int rc;
@@ -1867,7 +1864,6 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
   int output_progress;
 
   struct ImapAccountData *adata = imap_adata_get(m);
-  struct ImapMboxData *mdata = imap_mdata_get(m);
 
   if (!adata || adata->mailbox != m)
     return -1;
@@ -1883,23 +1879,6 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
       goto parsemsg;
   }
 
-  /* we still do some caching even if imap_cachedir is unset */
-  /* see if we already have the message in our cache */
-  cacheno = imap_edata_get(e)->uid % IMAP_CACHE_LEN;
-  cache = &mdata->cache[cacheno];
-
-  if (cache->path)
-  {
-    /* don't treat cache errors as fatal, just fall back. */
-    if (cache->uid == imap_edata_get(e)->uid && (msg->fp = fopen(cache->path, "r")))
-      return 0;
-    else
-    {
-      unlink(cache->path);
-      FREE(&cache->path);
-    }
-  }
-
   /* This function is called in a few places after endwin()
    * e.g. mutt_pipe_message(). */
   output_progress = !isendwin();
@@ -1908,17 +1887,7 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
 
   msg->fp = msg_cache_put(m, e);
   if (!msg->fp)
-  {
-    cache->uid = imap_edata_get(e)->uid;
-    mutt_mktemp(path, sizeof(path));
-    cache->path = mutt_str_strdup(path);
-    msg->fp = mutt_file_fopen(path, "w+");
-    if (!msg->fp)
-    {
-      FREE(&cache->path);
-      return -1;
-    }
-  }
+    return -1;
 
   /* mark this header as currently inactive so the command handler won't
    * also try to update it. HACK until all this code can be moved into the
@@ -2005,10 +1974,7 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
 
   fflush(msg->fp);
   if (ferror(msg->fp))
-  {
-    mutt_perror(cache->path);
     goto bail;
-  }
 
   if (rc != IMAP_CMD_OK)
     goto bail;
@@ -2067,12 +2033,6 @@ parsemsg:
 bail:
   mutt_file_fclose(&msg->fp);
   imap_cache_del(m, e);
-  if (cache->path)
-  {
-    unlink(cache->path);
-    FREE(&cache->path);
-  }
-
   return -1;
 }
 
index 95050fe875c120188a0c6a89d4b059f661174a92..f0ca6a04bd7e7684a42d0a45c0527aca23f591b2 100644 (file)
@@ -206,16 +206,6 @@ void imap_mdata_cache_reset(struct ImapMboxData *mdata)
   FREE(&mdata->msn_index);
   mdata->msn_index_size = 0;
   mdata->max_msn = 0;
-
-  for (int i = 0; i < IMAP_CACHE_LEN; i++)
-  {
-    if (mdata->cache[i].path)
-    {
-      unlink(mdata->cache[i].path);
-      FREE(&mdata->cache[i].path);
-    }
-  }
-
   mutt_bcache_close(&mdata->bcache);
 }