index-sync.c revision 52c6ec52ab53890c0c33d6bf85d47dfabaa38f77
/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "seq-range-array.h"
#include "array.h"
#include "buffer.h"
#include "index-storage.h"
struct index_mailbox_sync_context {
struct mailbox_sync_context ctx;
struct index_mailbox *ibox;
struct mail_index_view_sync_ctx *sync_ctx;
unsigned int expunge_pos;
bool failed;
};
{
return;
}
}
struct mail_index_view *view,
{
}
}
{
}
{
const struct mail_index_header *hdr;
unsigned int i, count, recent_count;
return 0;
for (i = count; i > 0; ) {
i--;
break;
/* completely invisible to this view */
} else {
/* partially invisible */
break;
}
}
return recent_count;
}
{
return;
}
}
struct mailbox_sync_context *
bool failed)
{
struct index_mailbox_sync_context *ctx;
enum mail_index_view_sync_flags sync_flags = 0;
if (failed) {
}
if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) != 0)
if ((flags & MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) != 0) {
ctx->messages_count = 0;
} else {
}
}
if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) {
}
}
struct mailbox_sync_rec *sync_rec)
{
else
else
return FALSE;
/* FIXME: we're only skipping messages from the beginning and from
the end. we should skip also the middle ones. This takes care of
the most common repeats though. */
/* skip expunged messages from the beginning and the end */
break;
}
/* everything skipped */
return FALSE;
}
break;
}
}
return TRUE;
}
static int
struct mailbox_sync_rec *sync_rec_r)
{
if (ctx->expunge_pos == 0)
return 0;
/* expunges is a sorted array of sequences. it's easiest for
us to print them from end to beginning. */
ctx->expunge_pos--;
return 1;
}
struct mailbox_sync_rec *sync_rec_r)
{
struct index_mailbox_sync_context *ctx =
(struct index_mailbox_sync_context *)_ctx;
struct mail_index_view_sync_rec sync;
return FALSE;
/* not interested */
break;
/* later */
break;
/* FIXME: hide the flag updates for expunged messages */
&sync_rec_r->seq1,
&sync_rec_r->seq2);
if (sync_rec_r->seq1 == 0)
break;
break;
sync_rec_r->type =
return 1;
}
}
}
static void
{
const struct mail_index_header *hdr;
return;
/* expunges array contained expunges for the messages that were already
visible in this view, but append+expunge would be invisible.
recent_flags may however contain the append UID, so we'll have to
remove it separately */
if (ctx->messages_count == 0)
uid = 0;
else {
return;
}
continue;
}
uid + 1,
}
#ifdef DEBUG
{
unsigned int i, count;
for (i = 0; i < count; i++) {
break;
}
}
}
#endif
}
struct mailbox_status *status_r)
{
struct index_mailbox_sync_context *ctx =
(struct index_mailbox_sync_context *)_ctx;
struct mailbox_sync_rec sync_rec;
const struct mail_index_header *hdr;
/* finish handling expunges, so we don't break when updating
recent flags */
ret = -1;
}
}
if (ibox->keep_recent) {
/* mailbox syncing didn't necessarily update our recent state */
if (seq1 != 0) {
}
}
}
if (ret == 0 && status_items != 0)
return ret;
}
{
if (!array_is_created(k1))
if (!array_is_created(k2))
return array_count(k1) == 0;
/* The arrays may not be sorted, but they usually are. Optimize for
the assumption that they are */
return FALSE;
for (i = 0; i < count1; i++) {
/* not found / unsorted array. check. */
for (j = 0; j < count1; j++) {
break;
}
if (j == count1)
return FALSE;
}
}
return TRUE;
}