cydir-save.c revision d22301419109ed4a38351715e6760011421dadec
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hostpid.h"
#include "istream.h"
#include "istream-crlf.h"
#include "ostream.h"
#include "str.h"
#include "index-mail.h"
#include "cydir-storage.h"
#include "cydir-sync.h"
#include <stdio.h>
#include <utime.h>
struct cydir_save_context {
struct mail_save_context ctx;
struct cydir_mailbox *mbox;
struct mail_index_transaction *trans;
char *tmp_basename;
unsigned int mail_count;
struct cydir_sync_context *sync_ctx;
/* updated for each appended mail: */
int fd;
unsigned int failed:1;
unsigned int finished:1;
};
static char *cydir_generate_tmp_filename(void)
{
static unsigned int create_count = 0;
return i_strdup_printf("temp.%s.P%sQ%uM%s.%s",
create_count++,
}
static const char *
{
const char *dir;
}
struct mail_save_context *
cydir_save_alloc(struct mailbox_transaction_context *t)
{
struct index_transaction_context *it =
(struct index_transaction_context *)t;
struct cydir_save_context *ctx =
(struct cydir_save_context *)t->save_ctx;
}
return t->save_ctx;
}
{
enum mail_flags save_flags;
struct istream *crlf_input;
return -1;
}
T_BEGIN {
const char *path;
} else {
"open(%s) failed: %m", path);
}
} T_END;
return -1;
/* add to index */
}
if (_ctx->min_modseq != 0) {
_ctx->min_modseq);
}
}
}
{
return -1;
do {
if (!mail_storage_set_error_from_errno(storage)) {
"o_stream_send_istream(%s) failed: %m",
}
return -1;
}
/* both tee input readers may consume data from our primary
input stream. we'll have to make sure we don't return with
one of the streams still having data in them. */
return 0;
}
{
"o_stream_flush(%s) failed: %m", path);
}
"fsync(%s) failed: %m", path);
}
}
else {
"fstat(%s) failed: %m", path);
}
} else {
"utime(%s) failed: %m", path);
}
}
"close(%s) failed: %m", path);
}
ctx->mail_count++;
else {
"unlink(%s) failed: %m", path);
}
}
}
{
(void)cydir_save_finish(_ctx);
}
{
const struct mail_index_header *hdr;
struct seq_range_iter iter;
const char *dir;
unsigned int n, src_prefixlen, dest_prefixlen;
return -1;
}
"rename(%s, %s) failed: %m",
return -1;
}
}
return 0;
}
{
result);
}
{
}