mdbox-save.c revision ac2dc6ef8db5f5fedbed94c5ff7261025657b5af
/* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "fdatasync-path.h"
#include "hex-binary.h"
#include "hex-dec.h"
#include "str.h"
#include "istream.h"
#include "istream-crlf.h"
#include "ostream.h"
#include "write-full.h"
#include "index-mail.h"
#include "mail-copy.h"
#include "dbox-save.h"
#include "mdbox-storage.h"
#include "mdbox-map.h"
#include "mdbox-file.h"
#include "mdbox-sync.h"
#include <stdlib.h>
struct dbox_save_mail {
struct dbox_file_append_context *file_append;
};
struct mdbox_save_context {
struct dbox_save_context ctx;
struct mdbox_mailbox *mbox;
struct mdbox_sync_context *sync_ctx;
struct dbox_file_append_context *cur_file_append;
struct dbox_map_append_context *append_ctx;
struct dbox_map_transaction_context *map_trans;
};
struct dbox_file *
{
struct mdbox_save_context *ctx =
(struct mdbox_save_context *)t->save_ctx;
unsigned int count;
}
struct mail_save_context *
mdbox_save_alloc(struct mailbox_transaction_context *t)
{
struct index_transaction_context *it =
(struct index_transaction_context *)t;
struct mdbox_save_context *ctx =
(struct mdbox_save_context *)t->save_ctx;
/* use the existing allocated structure */
}
return t->save_ctx;
}
{
struct dbox_save_mail *save_mail;
/* get the size of the mail to be saved, if possible */
mail_size = 0;
return -1;
}
}
struct dbox_save_mail *mail)
{
struct dbox_message_header dbox_msg_hdr;
/* save the 128bit GUID to index so if the map index gets corrupted
we can still find the message */
return -1;
}
return 0;
}
{
struct dbox_save_mail *mails;
return -1;
else
} T_END;
return -1;
}
return 0;
}
{
int ret;
return ret;
}
{
(void)mdbox_save_finish(_ctx);
}
{
const struct mail_index_header *hdr;
/* lock the mailbox before map to avoid deadlocks */
return -1;
}
/* get map UIDs for messages saved to multi-files. they're written
to transaction log immediately within this function, but the map
is left locked. */
&last_map_uid) < 0) {
return -1;
}
/* assign UIDs for new messages */
/* add map_uids for all messages saved to multi-files */
if (first_map_uid != 0) {
struct mdbox_mail_index_record rec;
const struct dbox_save_mail *mails;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
/* increase map's refcount for copied mails */
return -1;
}
}
return 0;
}
{
result);
/* finish writing the mailbox APPENDs */
/* commit only updates the sync tail offset, everything else
was already written at this point. */
}
i_error("fdatasync_path(%s) failed: %m",
}
}
}
{
}
{
struct mdbox_mailbox *src_mbox;
struct mdbox_mail_index_record rec;
const void *data;
bool expunged;
return -1;
/* remember the map_uid so we can later increase its refcount */
/* add message to mailbox index */
}
return 0;
}