Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7881:b8262c3a36f3 HEAD
mail_index_record_map_move_to_private(): Drop messages from record_map the
map hasn't itself seen yet.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 17 Jun 2008 13:59:47 +0300 |
parents | cca4ef877d43 |
children | ab08272053c5 |
files | src/lib-index/mail-index-map.c |
diffstat | 1 files changed, 21 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-map.c Tue Jun 17 13:57:48 2008 +0300 +++ b/src/lib-index/mail-index-map.c Tue Jun 17 13:59:47 2008 +0300 @@ -1134,16 +1134,29 @@ void mail_index_record_map_move_to_private(struct mail_index_map *map) { struct mail_index_record_map *new_map; + const struct mail_index_record *rec; - if (array_count(&map->rec_map->maps) == 1) - return; + if (array_count(&map->rec_map->maps) > 1) { + new_map = mail_index_record_map_alloc(map); + mail_index_map_copy_records(new_map, map->rec_map, + map->hdr.record_size); + mail_index_record_map_unlink(map); + map->rec_map = new_map; + } else { + new_map = map->rec_map; + } - new_map = mail_index_record_map_alloc(map); - mail_index_map_copy_records(new_map, map->rec_map, - map->hdr.record_size); - - mail_index_record_map_unlink(map); - map->rec_map = new_map; + if (new_map->records_count != map->hdr.messages_count) { + new_map->records_count = map->hdr.messages_count; + if (new_map->records_count == 0) + new_map->last_appended_uid = 0; + else { + rec = MAIL_INDEX_MAP_IDX(map, new_map->records_count-1); + new_map->last_appended_uid = rec->uid; + } + buffer_set_used_size(new_map->buffer, new_map->records_count * + map->hdr.record_size); + } } void mail_index_map_move_to_memory(struct mail_index_map *map)