sdbox-sync.c revision 2271d1a3dfc7191e610f039e86b9245bbc5dfb8c
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "str.h"
#include "hash.h"
#include "sdbox-storage.h"
#include "sdbox-file.h"
#include "sdbox-sync.h"
#define SDBOX_REBUILD_COUNT 3
static unsigned int sdbox_sync_file_entry_hash(const void *p)
{
const struct sdbox_sync_file_entry *entry = p;
}
{
/* this is only for hashing, don't bother ever returning 1. */
return -1;
return 0;
}
const struct mail_index_sync_rec *sync_rec,
{
*entry = lookup_entry;
}
else
return 1;
}
const struct mail_index_sync_rec *sync_rec)
{
int ret;
/* we're interested */
/* we care only about alt flag changes */
return 1;
} else {
/* not interested */
return 1;
}
/* already expunged everything. nothing to do. */
return 1;
}
return ret;
}
return 1;
}
{
const struct mail_index_header *hdr;
struct mail_index_sync_rec sync_rec;
struct hash_iterate_context *iter;
int ret = 1;
if (hdr->uid_validity == 0) {
/* newly created index file */
return 0;
}
/* mark the newly seen messages as recent */
}
/* read all changes and group changes to same file_id together */
break;
}
if (ret > 0) {
/* now sync each file separately */
break;
}
}
return ret;
}
static int
{
struct mail_index_view *view;
struct sdbox_index_header hdr;
int ret;
}
return ret;
}
struct sdbox_sync_context **ctx_r)
{
struct sdbox_sync_context *ctx;
unsigned int i;
int ret;
bool rebuild;
(flags & SDBOX_SYNC_FLAG_FORCE_REBUILD) != 0;
if ((flags & SDBOX_SYNC_FLAG_FSYNC) != 0)
/* don't write unnecessary dirty flag updates */
for (i = 0;; i++) {
if (ret <= 0) {
if (ret < 0)
return ret;
}
/* now that we're locked, check again if we want to rebuild. */
ret = 0;
else {
break;
}
/* failure. keep the index locked while we're doing a
rebuild. */
if (ret == 0) {
if (i >= SDBOX_REBUILD_COUNT) {
"dbox %s: Index keeps breaking",
ret = -1;
} else {
/* do a full resync and try again. */
i_warning("dbox %s: Rebuilding index",
}
}
if (ret < 0) {
return -1;
}
}
return 0;
}
{
if (success) {
ret = -1;
}
} else {
}
return ret;
}
{
struct sdbox_sync_context *sync_ctx;
return -1;
return 0;
}
struct mailbox_sync_context *
{
enum sdbox_sync_flags sdbox_sync_flags = 0;
int ret = 0;
if (mailbox_open(box) < 0)
ret = -1;
}
if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)
}
}