Changeset 5034:f467353f5657

Show
Ignore:
Timestamp:
2007-03-31 18:50:39 (20 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
default
Message:

Add tmp flag to bcache_put, create bcache_commit.

Files:
6 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5032 r5034  
     12007-03-31 16:07 -0700  Brendan Cully  <brendan@kublai.com>  (bf208df92829) 
     2 
     3        * imap/command.c, imap/imap.c: Allow IMAP FCC to reconnect if 
     4        append fails (closes: #890) 
     5 
     6        * mh.c: Always set up data pointer in mh_read_dir, not just when 
     7        allocating context 
     8 
    192007-03-30 21:26 -0700  Daniel Burrows  <dburrows@debian.org>  (d5ab883ef90a) 
    210 
  • bcache.c

    r5020 r5034  
    132132} 
    133133 
    134 FILE* mutt_bcache_put(body_cache_t *bcache, const char *id) 
     134FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp) 
    135135{ 
    136136  char path[_POSIX_PATH_MAX]; 
     
    142142    return NULL; 
    143143 
    144   path[0] = '\0'; 
    145   safe_strncat (path, sizeof (path), bcache->path, bcache->pathlen); 
    146   safe_strncat (path, sizeof (path), id, mutt_strlen (id)); 
     144  snprintf (path, sizeof (path), "%s%s%s", bcache->path, id, 
     145            tmp ? ".tmp" : ""); 
    147146 
    148147  s = strchr (path + 1, '/'); 
     
    162161} 
    163162 
     163int mutt_bcache_commit(body_cache_t* bcache, const char* id) 
     164{ 
     165  char tmpid[_POSIX_PATH_MAX]; 
     166 
     167  snprintf (tmpid, sizeof (tmpid), "%s.tmp", id); 
     168 
     169  return mutt_bcache_move (bcache, tmpid, id); 
     170} 
     171 
    164172int mutt_bcache_move(body_cache_t* bcache, const char* id, const char* newid) 
    165173{ 
  • bcache.h

    r5020 r5034  
    4949 
    5050FILE* mutt_bcache_get(body_cache_t *bcache, const char *id); 
    51 FILE* mutt_bcache_put(body_cache_t *bcache, const char *id); 
     51/* tmp: the returned FILE* is in a temporary location. 
     52 *      if set, use mutt_bcache_commit to put it into place */ 
     53FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp); 
     54int mutt_bcache_commit(body_cache_t *bcache, const char *id); 
    5255int mutt_bcache_move(body_cache_t *bcache, const char *id, const char *newid); 
    5356int mutt_bcache_del(body_cache_t *bcache, const char *id); 
  • imap/message.c

    r5020 r5034  
    904904 
    905905  idata->bcache = msg_cache_open (idata); 
    906   snprintf (id, sizeof (id), "%u-%u.tmp", idata->uid_validity, HEADER_DATA(h)->uid); 
    907   return mutt_bcache_put (idata->bcache, id); 
     906  snprintf (id, sizeof (id), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid); 
     907  return mutt_bcache_put (idata->bcache, id, 1); 
    908908} 
    909909 
     
    911911{ 
    912912  char id[_POSIX_PATH_MAX]; 
    913   char newid[_POSIX_PATH_MAX]; 
    914913 
    915914  if (!idata || !h) 
     
    917916 
    918917  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); 
     918  snprintf (id, sizeof (id), "%u-%u", idata->uid_validity, HEADER_DATA(h)->uid); 
     919 
     920  return mutt_bcache_commit (idata->bcache, id); 
    923921} 
    924922 
  • pop.c

    r5027 r5034  
    429429 
    430430/* close POP mailbox */ 
    431 void pop_close_mailbox (CONTEXT *ctx) 
     431int pop_close_mailbox (CONTEXT *ctx) 
    432432{ 
    433433  POP_DATA *pop_data = (POP_DATA *)ctx->data; 
    434434 
    435435  if (!pop_data) 
    436     return; 
     436    return 0; 
    437437 
    438438  pop_logout (ctx); 
     
    451451  mutt_bcache_close (&pop_data->bcache); 
    452452 
    453   return; 
     453  return 0; 
    454454} 
    455455 
     
    515515 
    516516    /* see if we can put in body cache; use our cache as fallback */ 
    517     if (!(msg->fp = mutt_bcache_put (pop_data->bcache, h->data))) 
     517    if (!(msg->fp = mutt_bcache_put (pop_data->bcache, h->data, 1))) 
    518518    { 
    519519      /* no */ 
     
    539539     * the file in bcache or from POP's own cache since the next iteration 
    540540     * of the loop will re-attempt to put() the message */ 
    541     if (bcache) 
    542       mutt_bcache_del (pop_data->bcache, h->data); 
    543     else 
     541    if (!bcache) 
    544542      unlink (path); 
    545543 
     
    562560   * portion of the headers, those required for the main display. 
    563561   */ 
    564   if (!bcache) 
     562  if (bcache) 
     563    mutt_bcache_commit (pop_data->bcache, h->data); 
     564  else 
    565565  { 
    566566    cache->index = h->index; 
  • pop.h

    r4682 r5034  
    110110int pop_sync_mailbox (CONTEXT *, int *); 
    111111int pop_fetch_message (MESSAGE *, CONTEXT *, int); 
    112 void pop_close_mailbox (CONTEXT *); 
     112int pop_close_mailbox (CONTEXT *); 
    113113void pop_fetch_mail (void); 
    114114