mail-index-sync-update.c revision f3a258b0930595dedaa4057d4104d99d4409a10e
/* Copyright (C) 2004 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "buffer.h"
#include "file-set-size.h"
#include "mmap-util.h"
#include "mail-index-view-private.h"
#include "mail-index-sync-private.h"
#include "mail-transaction-log.h"
#include "mail-transaction-util.h"
#include "mail-cache-private.h"
#include <time.h>
static void
{
/* different recent-flag */
if ((old_flags & MAIL_RECENT) == 0)
else if (--hdr->recent_messages_count == 0)
}
/* different seen-flag */
}
/* different deleted-flag */
if ((old_flags & MAIL_DELETED) == 0)
else if (--hdr->deleted_messages_count == 0)
}
}
static void
const struct mail_index_record *rec)
{
}
{
if (!ctx->update_cache)
return;
if (!ctx->cache_locked) {
return;
}
}
{
struct mail_index_record *rec;
return -1;
if (seq1 == 0)
return 1;
if (rec->cache_offset != 0)
}
/* @UNSAFE */
}
return 1;
}
{
void *dest;
"Append with UID %u, but next_uid = %u",
return -1;
}
if (MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
} else {
}
view->messages_count++;
map->records_count++;
return 1;
}
static int sync_flag_update(const struct mail_transaction_flag_update *u,
void *context)
{
struct mail_index_record *rec;
struct mail_index_header *hdr;
int update_keywords;
return -1;
if (seq1 == 0)
return 1;
if ((u->add_flags & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0)
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
if (u->add_keywords[i] != 0 ||
u->remove_keywords[i] != 0)
keyword_mask[i] = ~u->remove_keywords[i];
}
flag_mask = ~u->remove_flags;
if (update_keywords) {
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
}
}
}
return 1;
}
static int sync_cache_reset(const struct mail_transaction_cache_reset *u,
void *context)
{
uint32_t i;
for (i = 0; i < view->messages_count; i++)
return 1;
}
static int sync_cache_update(const struct mail_transaction_cache_update *u,
void *context)
{
struct mail_index_record *rec;
int ret;
return -1;
if (seq == 0) {
/* already expunged */
return 1;
}
/* we'll need to link the old and new cache records */
if (!ctx->cache_locked) {
}
return -1;
}
return 1;
}
static int sync_header_update(const struct mail_transaction_header_update *u,
void *context)
{
void *data;
return 1;
}
static int
const struct mail_transaction_extra_rec_update *u,
void *context)
{
struct mail_index_record *rec;
/* FIXME: do data_id mapping conversion */
return -1;
if (seq != 0) {
}
return 1;
}
unsigned int count)
{
struct mail_index_header hdr;
return 0;
return 0;
/* when we grow fast, do it exponentially */
if (count < MAIL_INDEX_MAX_POWER_GROW)
/* we only wish to grow the file, but mail_index_map() updates the
headers as well and may break our modified hdr_copy. so, take
a backup of it and put it back afterwards */
return -1;
return 0;
}
struct mail_index_map *map)
{
}
static void
{
const int max_days =
int i, days;
/* get beginning of today */
i_panic("mktime(today) failed");
return;
/* get number of days since last message */
/* @UNSAFE: move days forward and fill the missing days with old
day_first_uid[0]. */
for (i = 1; i < days; i++)
}
{
struct mail_index_map *map;
struct mail_index_sync_map_ctx sync_map_ctx;
const struct mail_transaction_header *hdr;
const void *data;
unsigned int count, old_lock_id;
/* we'll have to update view->lock_id to avoid mail_index_view_lock()
trying to update the file later. */
return -1;
/* NOTE: locking may change index->map so make sure assignment
after locking */
first_append_uid = 0;
if (had_dirty)
!map->write_to_disk) {
/* expunges have to be atomic. so we'll have to copy
the mapping, do the changes there and then finally
replace the whole index file. to avoid extra disk
I/O we copy the index into memory rather than to
temporary file */
}
const struct mail_transaction_append_header *append_hdr;
const struct mail_index_record *rec;
if (first_append_uid == 0)
append_hdr = data;
/* we have to grow our record size */
}
ret = -1;
break;
}
}
&sync_map_ctx) < 0) {
ret = -1;
break;
}
}
if (sync_map_ctx.cache_locked) {
}
if (ret < 0) {
return -1;
}
if (first_append_uid != 0)
had_dirty) {
/* do we have dirty flags anymore? */
const struct mail_index_record *rec;
for (i = 0; i < map->records_count; i++) {
break;
}
}
}
if (!MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
ret = -1;
}
}
return ret;
}
};