Show
Ignore:
Timestamp:
2007-04-10 20:22:06 (21 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

Add $message_cache_clean option to prune message cache on sync

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • imap/message.c

    r5115 r5120  
    907907} 
    908908 
     909static int msg_cache_clean_cb (const char* id, body_cache_t* bcache, void* data) 
     910{ 
     911  unsigned int uv, uid, n; 
     912  IMAP_DATA* idata = (IMAP_DATA*)data; 
     913 
     914  if (sscanf (id, "%u-%u", &uv, &uid) != 2) 
     915    return 0; 
     916 
     917  /* bad UID */ 
     918  if (uv != idata->uid_validity) 
     919    mutt_bcache_del (bcache, id); 
     920 
     921  /* TODO: presort UIDs, walk in order */ 
     922  for (n = 0; n < idata->ctx->msgcount; n++) 
     923  { 
     924    if (uid == HEADER_DATA(idata->ctx->hdrs[n])->uid) 
     925      return 0; 
     926  } 
     927  mutt_bcache_del (bcache, id); 
     928 
     929  return 0; 
     930} 
     931 
     932int imap_cache_clean (IMAP_DATA* idata) 
     933{ 
     934  idata->bcache = msg_cache_open (idata); 
     935  mutt_bcache_list (idata->bcache, msg_cache_clean_cb, idata); 
     936 
     937  return 0; 
     938} 
     939 
    909940/* imap_add_keywords: concatenate custom IMAP tags to list, if they 
    910941 *   appear in the folder flags list. Why wouldn't they? */