Changeset 5120:429fb67340cd

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:
7 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5118 r5120  
    1 2007-04-10 19:19 -0700  Brendan Cully  <brendan@kublai.com>  (ddd38b4cf15c) 
     12007-04-10 19:28 -0700  Brendan Cully  <brendan@kublai.com>  (d12143e1a610) 
     2 
     3        * hcache.c: Try to unlink old header cache if open fails 
     4 
     5        * bcache.c, imap/imap.c, imap/util.c, lib.c: Fix some warnings 
    26 
    37        * hcache.c: Refactor mutt_hcache_open to share more code 
  • UPDATING

    r5087 r5120  
    44The keys used are: 
    55  !: modified feature, -: deleted feature, +: new feature 
     6 
     7  + $message_cache_clean (clean cache on sync) 
    68 
    791.5.15 (2007-04-06) 
  • imap/imap.c

    r5118 r5120  
    12621262  } 
    12631263 
     1264  if (option (OPTMESSAGECACHECLEAN)) 
     1265    imap_cache_clean (idata); 
     1266 
    12641267  rc = 0; 
     1268 
    12651269 out: 
    12661270  if (cmd.data) 
  • imap/imap_private.h

    r5115 r5120  
    257257char* imap_set_flags (IMAP_DATA* idata, HEADER* h, char* s); 
    258258int imap_cache_del (IMAP_DATA* idata, HEADER* h); 
     259int imap_cache_clean (IMAP_DATA* idata); 
    259260 
    260261/* util.c */ 
  • 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? */ 
  • init.h

    r5064 r5120  
    12951295  ** time, for instance if stale entries accumulate because you have 
    12961296  ** deleted messages with another mail client. 
     1297  */ 
     1298  { "message_cache_clean", DT_BOOL, R_NONE, OPTMESSAGECACHECLEAN, 0 }, 
     1299  /* 
     1300  ** .pp 
     1301  ** If set, mutt will clean out obsolete entries from the cache when 
     1302  ** the mailbox is synchronized. You probably only want to set it 
     1303  ** every once in a while, since it can be a little slow. 
    12971304  */ 
    12981305#endif 
  • mutt.h

    r5029 r5120  
    401401  OPTMENUSCROLL,        /* scroll menu instead of implicit next-page */ 
    402402  OPTMENUMOVEOFF,       /* allow menu to scroll past last entry */ 
     403#if defined(USE_IMAP) || defined(USE_POP) 
     404  OPTMESSAGECACHECLEAN, 
     405#endif 
    403406  OPTMETAKEY,           /* interpret ALT-x as ESC-x */ 
    404407  OPTMETOO,