sdbox-storage.c revision 7baab0b0b60df7ce9093d0881cd322dff1e79491
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "master-service.h"
#include "mail-index-modseq.h"
#include "mail-search-build.h"
#include "mailbox-list-private.h"
#include "dbox-mail.h"
#include "dbox-save.h"
#include "sdbox-file.h"
#include "sdbox-sync.h"
#include "sdbox-storage.h"
extern struct mailbox sdbox_mailbox;
extern struct dbox_storage_vfuncs sdbox_dbox_storage_vfuncs;
static struct mail_storage *sdbox_storage_alloc(void)
{
struct sdbox_storage *storage;
}
static struct mailbox *
{
struct sdbox_mailbox *mbox;
struct index_mailbox_context *ibox;
/* dbox can't work without index files */
}
{
struct mail_index_view *view;
const void *data;
int ret;
if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
if (log_error) {
"sdbox %s: Invalid dbox header size",
}
ret = -1;
} else {
ret = 0;
}
return ret;
}
struct mail_index_transaction *trans,
const struct mailbox_update *update)
{
sizeof(new_hdr.mailbox_guid));
}
}
}
const struct mailbox_update *update,
struct mail_index_transaction *trans)
{
const struct mail_index_header *hdr;
}
else if (hdr->uid_validity != 0)
else {
/* set uidvalidity */
}
if (hdr->uid_validity != 0) {
/* UIDVALIDITY change requires index to be reset */
}
}
}
}
if (mail_index_transaction_commit(&new_trans) < 0) {
return -1;
}
}
return 0;
}
static const char *
{
return t_strdup_printf("-%s-%u",
}
{
struct sdbox_index_header hdr;
else
}
{
}
{
struct sdbox_index_header hdr;
if (dbox_mailbox_open(box) < 0)
return -1;
mbox->hdr_ext_id =
sizeof(struct sdbox_index_header), 0, 0);
/* wait for mailbox creation to initialize the index */
return 0;
}
/* it's possible that this mailbox is just now being created
by another process. lock it first and see if the header is
available then. */
struct mail_index_sync_ctx *sync_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
(void)mail_index_sync_commit(&sync_ctx);
}
/* regenerate it */
return -1;
}
sizeof(mbox->mailbox_guid));
return 0;
}
{
if (mbox->corrupted_rebuild_count != 0)
(void)sdbox_sync(mbox, 0);
}
{
struct mail_search_context *ctx;
struct mailbox_transaction_context *t;
struct mail_search_args *search_args;
struct sdbox_file *sfile;
return index_storage_mailbox_delete(box);
/* mark the mailbox deleted to avoid race conditions */
return -1;
/* ulink all dbox mails and their attachements in the mailbox. */
t = mailbox_transaction_begin(box, 0);
}
if (mailbox_search_deinit(&ctx) < 0) {
/* maybe we missed some mails. oh well, can't help it. */
}
return index_storage_mailbox_delete(box);
}
static int
enum mailbox_metadata_items items,
struct mailbox_metadata *metadata_r)
{
if ((items & MAILBOX_METADATA_GUID) != 0) {
}
}
static int
{
if (mailbox_open(box) < 0)
return -1;
}
}
struct mail_storage sdbox_storage = {
.class_flags = 0,
.v = {
NULL,
NULL,
NULL,
}
};
struct mail_storage dbox_storage = {
.class_flags = 0,
.v = {
NULL,
NULL,
NULL,
}
};
struct mailbox sdbox_mailbox = {
.v = {
NULL,
NULL,
}
};
struct dbox_storage_vfuncs sdbox_dbox_storage_vfuncs = {
};