cydir-save.c revision e3aeeb634245e80d4f643f8d2eea11d6b72336d8
/* Copyright (c) 2007-2008 Dovecot authors, see the included COPYING file */
#include "lib.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 *
{
struct cydir_transaction_context *t =
(struct cydir_transaction_context *)_t;
}
{
enum mail_flags save_flags;
struct istream *crlf_input;
T_BEGIN {
const char *path;
} else {
"open(%s) failed: %m", path);
}
} T_END;
return -1;
/* add to index */
}
}
}
{
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);
}
{
struct cydir_transaction_context *t =
const struct mail_index_header *hdr;
const char *dir;
unsigned int src_prefixlen, dest_prefixlen;
return -1;
}
"rename(%s, %s) failed: %m",
return -1;
}
}
return 0;
}
{
}
{
}