Changeset 5020:034ad0e55397 for imap

Show
Ignore:
Timestamp:
2007-03-29 10:30:15 (20 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
default
Message:

Make message cache write to temporary location until file is complete.
Previously mutt trusted the cache file even when it was incomplete,
causing permanently incorrect message display if the fetch was
interrupted for some reason.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • imap/message.c

    r4923 r5020  
    4646static FILE* msg_cache_get (IMAP_DATA* idata, HEADER* h); 
    4747static FILE* msg_cache_put (IMAP_DATA* idata, HEADER* h); 
     48static int msg_cache_commit (IMAP_DATA* idata, HEADER* h); 
    4849 
    4950static void flush_buffer(char* buf, size_t* len, CONNECTION* conn); 
     
    501502    goto bail; 
    502503 
    503 parsemsg: 
     504  msg_cache_commit (idata, h); 
     505 
     506  parsemsg: 
    504507  /* Update the header information.  Previously, we only downloaded a 
    505508   * portion of the headers, those required for the main display. 
     
    901904 
    902905  idata->bcache = msg_cache_open (idata); 
    903   snprintf (id, sizeof (id), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid); 
     906  snprintf (id, sizeof (id), "%u-%u.tmp", idata->uid_validity, HEADER_DATA(h)->uid); 
    904907  return mutt_bcache_put (idata->bcache, id); 
     908} 
     909 
     910static int msg_cache_commit (IMAP_DATA* idata, HEADER* h) 
     911{ 
     912  char id[_POSIX_PATH_MAX]; 
     913  char newid[_POSIX_PATH_MAX]; 
     914 
     915  if (!idata || !h) 
     916    return -1; 
     917 
     918  idata->bcache = msg_cache_open (idata); 
     919  snprintf (id, sizeof (id), "%u-%u.tmp", idata->uid_validity, HEADER_DATA(h)->uid); 
     920  snprintf (newid, sizeof (newid), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid); 
     921 
     922  return mutt_bcache_move (idata->bcache, id, newid); 
    905923} 
    906924