Mercurial > dovecot > original-hg > dovecot-1.2
view src/lib-index/mail-index-update-cache.c @ 25:55e09f36d23d HEAD
after a few times of trying to access uncached fields, they're cached the
next time mailbox is opened. also some mbox fixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 25 Aug 2002 23:50:09 +0300 |
parents | |
children | 5e9cf9565353 |
line wrap: on
line source
/* Copyright (C) 2002 Timo Sirainen */ #include "lib.h" #include "mail-index.h" static int cache_record(MailIndex *index, MailIndexRecord *rec, MailField cache_fields) { MailIndexUpdate *update; IOBuffer *inbuf; inbuf = index->open_mail(index, rec); if (inbuf == NULL) return FALSE; cache_fields &= ~rec->cached_fields; update = index->update_begin(index, rec); mail_index_update_headers(update, inbuf, cache_fields, NULL, NULL); return index->update_end(update); } int mail_index_update_cache(MailIndex *index) { MailIndexRecord *rec; MailField cache_fields; if (!index->set_lock(index, MAIL_LOCK_EXCLUSIVE)) return FALSE; cache_fields = index->get_header(index)->cache_fields; rec = index->lookup(index, 1); while (rec != NULL) { if ((rec->cached_fields & cache_fields) != cache_fields) { if (!cache_record(index, rec, cache_fields)) return FALSE; } rec = index->next(index, rec); } index->header->flags &= ~MAIL_INDEX_FLAG_CACHE_FIELDS; return TRUE; }