comparison src/lib-index/mail-cache-transaction.c @ 6589:0e46072f797a HEAD

Don't give "Newly added field got lost unexpectedly" errors when cache file is created while adding a new field.
author Timo Sirainen <tss@iki.fi>
date Sun, 21 Oct 2007 15:39:42 +0300
parents 5ad7a36ca8c3
children f3ca0b9e3628
comparison
equal deleted inserted replaced
6588:fd01ec16611f 6589:0e46072f797a
720 { 720 {
721 struct mail_cache *cache = ctx->cache; 721 struct mail_cache *cache = ctx->cache;
722 buffer_t *buffer; 722 buffer_t *buffer;
723 int ret; 723 int ret;
724 724
725 cache->fields[field_idx].last_used = ioloop_time;
726 cache->fields[field_idx].used = TRUE;
727
728 if ((ret = mail_cache_transaction_lock(ctx)) <= 0) { 725 if ((ret = mail_cache_transaction_lock(ctx)) <= 0) {
729 /* create the cache file if it doesn't exist yet */ 726 /* create the cache file if it doesn't exist yet */
730 if (ctx->tried_compression) 727 if (ctx->tried_compression)
731 return -1; 728 return -1;
732 ctx->tried_compression = TRUE; 729 ctx->tried_compression = TRUE;
740 /* re-read header to make sure we don't lose any fields. */ 737 /* re-read header to make sure we don't lose any fields. */
741 if (mail_cache_header_fields_read(cache) < 0) { 738 if (mail_cache_header_fields_read(cache) < 0) {
742 (void)mail_cache_unlock(cache); 739 (void)mail_cache_unlock(cache);
743 return -1; 740 return -1;
744 } 741 }
742
743 /* update these only after reading */
744 cache->fields[field_idx].last_used = ioloop_time;
745 cache->fields[field_idx].used = TRUE;
745 746
746 if (cache->field_file_map[field_idx] != (uint32_t)-1) { 747 if (cache->field_file_map[field_idx] != (uint32_t)-1) {
747 /* it was already added */ 748 /* it was already added */
748 if (mail_cache_unlock(cache) < 0) 749 if (mail_cache_unlock(cache) < 0)
749 return -1; 750 return -1;