cydir-save.c revision 89a126810703c666309310d0f3189e9834d70b5b
/* Copyright (c) 2007-2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "hostpid.h"
#include "istream.h"
#include "ostream.h"
#include "ostream-crlf.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;
}
const char *from_envelope ATTR_UNUSED,
struct mail_save_context **ctx_r)
{
struct cydir_transaction_context *t =
(struct cydir_transaction_context *)_t;
enum mail_flags save_flags;
const char *path;
}
t_push();
} else {
"open(%s) failed: %m", path);
t_pop();
return -1;
}
t_pop();
/* 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;
}
{
}
{
}