mail-index-transaction.c revision b35f7104715edee0cfac6d46ab0b342033867eb7
/* Copyright (C) 2003-2004 Timo Sirainen */
/* Inside transaction we keep messages stored in sequences in uid fields.
Before they're written to transaction log the sequences are changed to
UIDs. This is because we're able to compress sequence ranges better. */
#include "lib.h"
#include "buffer.h"
#include "mail-index-view-private.h"
#include "mail-transaction-log.h"
#include "mail-index-transaction-private.h"
static void mail_index_transaction_add_last(struct mail_index_transaction *t);
struct mail_index_transaction *
{
struct mail_index_transaction *t;
/* don't allow syncing view while there's ongoing transactions */
t->hide_transaction = hide;
return t;
}
static void mail_index_transaction_free(struct mail_index_transaction *t)
{
buffer_free(t->appends);
buffer_free(t->expunges);
buffer_free(t->updates);
i_free(t);
}
static void
{
unsigned char *data;
return;
/* @UNSAFE */
for (i = 0; i < size; i += record_size) {
if (range)
}
}
static int
{
if (mail_index_view_lock(t->view) < 0)
return -1;
sizeof(struct mail_transaction_expunge), TRUE);
sizeof(struct mail_transaction_flag_update), TRUE);
sizeof(struct mail_transaction_cache_update), TRUE);
return 0;
}
int mail_index_transaction_commit(struct mail_index_transaction *t,
{
int ret;
if (mail_index_view_is_inconsistent(t->view)) {
return -1;
}
if (t->last_update.uid1 != 0)
if (mail_index_transaction_convert_to_uids(t) < 0)
ret = -1;
else {
}
return ret;
}
void mail_index_transaction_rollback(struct mail_index_transaction *t)
{
}
{
struct mail_index_record *rec;
}
/* sequence number is visible only inside given view,
so let it generate it */
if (t->last_new_seq != 0)
*seq_r = ++t->last_new_seq;
else {
}
}
{
/* expunges is a sorted array of {seq1, seq2, ..}, .. */
return;
}
/* quick checks */
/* grow last range */
return;
}
return;
}
/* grow down first range */
return;
}
return;
}
/* somewhere in the middle, array is sorted so find it with
binary search */
else
break;
}
idx++;
/* idx == size couldn't happen because we already handle it above */
/* already expunged */
return;
}
/* merge */
sizeof(*data));
}
/* merge */
sizeof(*data));
}
} else {
}
}
enum modify_type modify_type,
enum mail_flags flags,
{
int i;
switch (modify_type) {
case MODIFY_REPLACE:
break;
case MODIFY_ADD:
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
break;
case MODIFY_REMOVE:
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
break;
}
}
((t)->last_update_modify_type == (modify_type) && \
INDEX_KEYWORDS_BYTE_COUNT) == 0)
enum modify_type modify_type,
{
struct mail_index_record *rec;
/* just appended message, modify it directly */
return;
}
/* first get group updates into same structure. this allows faster
updates if same mails have multiple flag updates during same
transaction (eg. 1:10 +seen, 1:10 +deleted) */
if (t->last_update.uid1 != 0 &&
return;
}
if (t->last_update.uid1 != 0 &&
return;
}
}
if (t->last_update.uid1 != 0)
}
static void
struct mail_transaction_flag_update *update)
{
int i;
*update = t->last_update;
switch (t->last_update_modify_type) {
case MODIFY_REPLACE:
/* remove_flags = ~add_flags */
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++)
break;
case MODIFY_ADD:
/* already in add_flags */
break;
case MODIFY_REMOVE:
/* add_flags -> remove_flags */
break;
}
}
static void mail_index_transaction_add_last(struct mail_index_transaction *t)
{
}
/* find the nearest sequence from existing updates */
else
break;
}
idx++;
/* insert it into buffer, split it in multiple parts if needed
to make sure the ordering stays the same */
break;
/* partial */
size++;
}
}
}
void mail_index_update_cache(struct mail_index_transaction *t,
{
if (t->cache_updates == NULL) {
}
/* we're probably appending it, check */
else {
else {
/* already there, update */
return;
}
}
}
}