Changeset 5034:f467353f5657
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5032
|
r5034
|
|
| | 1 | 2007-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 | |
| 1 | 9 | 2007-03-30 21:26 -0700 Daniel Burrows <dburrows@debian.org> (d5ab883ef90a) |
| 2 | 10 | |
-
|
r5020
|
r5034
|
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | | FILE* mutt_bcache_put(body_cache_t *bcache, const char *id) |
| | 134 | FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp) |
| 135 | 135 | { |
| 136 | 136 | char path[_POSIX_PATH_MAX]; |
| … |
… |
|
| 142 | 142 | return NULL; |
| 143 | 143 | |
| 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" : ""); |
| 147 | 146 | |
| 148 | 147 | s = strchr (path + 1, '/'); |
| … |
… |
|
| 162 | 161 | } |
| 163 | 162 | |
| | 163 | int 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 | |
| 164 | 172 | int mutt_bcache_move(body_cache_t* bcache, const char* id, const char* newid) |
| 165 | 173 | { |
-
|
r5020
|
r5034
|
|
| 49 | 49 | |
| 50 | 50 | FILE* 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 */ |
| | 53 | FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp); |
| | 54 | int mutt_bcache_commit(body_cache_t *bcache, const char *id); |
| 52 | 55 | int mutt_bcache_move(body_cache_t *bcache, const char *id, const char *newid); |
| 53 | 56 | int mutt_bcache_del(body_cache_t *bcache, const char *id); |
-
|
r5020
|
r5034
|
|
| 904 | 904 | |
| 905 | 905 | 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); |
| 908 | 908 | } |
| 909 | 909 | |
| … |
… |
|
| 911 | 911 | { |
| 912 | 912 | char id[_POSIX_PATH_MAX]; |
| 913 | | char newid[_POSIX_PATH_MAX]; |
| 914 | 913 | |
| 915 | 914 | if (!idata || !h) |
| … |
… |
|
| 917 | 916 | |
| 918 | 917 | 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); |
| 923 | 921 | } |
| 924 | 922 | |
-
|
r5027
|
r5034
|
|
| 429 | 429 | |
| 430 | 430 | /* close POP mailbox */ |
| 431 | | void pop_close_mailbox (CONTEXT *ctx) |
| | 431 | int pop_close_mailbox (CONTEXT *ctx) |
| 432 | 432 | { |
| 433 | 433 | POP_DATA *pop_data = (POP_DATA *)ctx->data; |
| 434 | 434 | |
| 435 | 435 | if (!pop_data) |
| 436 | | return; |
| | 436 | return 0; |
| 437 | 437 | |
| 438 | 438 | pop_logout (ctx); |
| … |
… |
|
| 451 | 451 | mutt_bcache_close (&pop_data->bcache); |
| 452 | 452 | |
| 453 | | return; |
| | 453 | return 0; |
| 454 | 454 | } |
| 455 | 455 | |
| … |
… |
|
| 515 | 515 | |
| 516 | 516 | /* 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))) |
| 518 | 518 | { |
| 519 | 519 | /* no */ |
| … |
… |
|
| 539 | 539 | * the file in bcache or from POP's own cache since the next iteration |
| 540 | 540 | * 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) |
| 544 | 542 | unlink (path); |
| 545 | 543 | |
| … |
… |
|
| 562 | 560 | * portion of the headers, those required for the main display. |
| 563 | 561 | */ |
| 564 | | if (!bcache) |
| | 562 | if (bcache) |
| | 563 | mutt_bcache_commit (pop_data->bcache, h->data); |
| | 564 | else |
| 565 | 565 | { |
| 566 | 566 | cache->index = h->index; |
-
|
r4682
|
r5034
|
|
| 110 | 110 | int pop_sync_mailbox (CONTEXT *, int *); |
| 111 | 111 | int pop_fetch_message (MESSAGE *, CONTEXT *, int); |
| 112 | | void pop_close_mailbox (CONTEXT *); |
| | 112 | int pop_close_mailbox (CONTEXT *); |
| 113 | 113 | void pop_fetch_mail (void); |
| 114 | 114 | |