mail-index-sync-update.c revision 0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834
/* Copyright (C) 2004 Timo Sirainen */
#include "lib.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"
struct mail_index_update_ctx {
struct mail_index *index;
struct mail_index_header hdr;
struct mail_transaction_log_view *log_view;
};
{
/* different seen-flag */
else
}
/* different deleted-flag */
if ((old_flags & MAIL_DELETED) == 0)
else
}
}
const struct mail_index_record *rec)
{
}
{
struct mail_index_record *rec;
}
struct mail_index_sync_rec *syncrec)
{
int i, update_custom;
for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
if (syncrec->add_custom_flags[i] != 0)
if (syncrec->remove_custom_flags[i] != 0)
}
if (update_custom) {
for (i = 0; i < INDEX_CUSTOM_FLAGS_BYTE_COUNT; i++) {
rec->custom_flags[i] =
syncrec->add_custom_flags[i];
}
}
}
}
{
unsigned int records_count;
// FIXME: grow exponentially
count * sizeof(struct mail_index_record);
return -1;
return 0;
}
const struct mail_index_record *appends,
unsigned int count)
{
unsigned int i;
// FIXME
}
return -1;
PROT_READ|PROT_WRITE) < 0) {
return -1;
}
}
for (i = 0; i < count; i++) {
/* FIXME: should we rather just update the record?
this can actually happen if append was written to
transaction log but index wasn't updated, then
another sync wrote it again.. */
"Append with UID %u, but next_uid = %u",
return -1;
}
}
return 0;
}
{
struct mail_index_update_ctx ctx;
struct mail_index_sync_rec rec;
const struct mail_index_record *appends;
unsigned int append_count;
/* rewind */
break;
if (src_idx != 0) {
} else {
if (mail_index_lock_exclusive_copy(index) <= 0)
return -1;
PROT_READ|PROT_WRITE) < 0) {
"mprotect()");
return -1;
}
}
break;
break;
}
}
if (src_idx != 0) {
}
ret = 0;
if (append_count > 0)
} else {
// FIXME
}
if (locked)
mail_index_unlock(index, 0);
return ret;
}