return;
struct Email *e = NULL;
- int cacheno;
short old_sort;
#ifdef USE_HCACHE
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);
IMAP_CAP_MAX,
};
-/**
- * struct ImapCache - IMAP-specific message cache
- */
-struct ImapCache
-{
- unsigned int uid;
- char *path;
-};
-
/**
* struct ImapList - Items in an IMAP browser
*/
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 */
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;
int output_progress;
struct ImapAccountData *adata = imap_adata_get(m);
- struct ImapMboxData *mdata = imap_mdata_get(m);
if (!adata || adata->mailbox != m)
return -1;
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();
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
fflush(msg->fp);
if (ferror(msg->fp))
- {
- mutt_perror(cache->path);
goto bail;
- }
if (rc != IMAP_CMD_OK)
goto bail;
bail:
mutt_file_fclose(&msg->fp);
imap_cache_del(m, e);
- if (cache->path)
- {
- unlink(cache->path);
- FREE(&cache->path);
- }
-
return -1;
}
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);
}