mail-index-write.c revision 44d77d20cbe158306fcc2d4b49aa883b8f8dbc83
/* Copyright (c) 2003-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "read-full.h"
#include "write-full.h"
#include "ostream.h"
#include "mail-index-private.h"
#include "mail-transaction-log-private.h"
#include <stdio.h>
#define MAIL_INDEX_MIN_UPDATE_SIZE 1024
/* if we're updating >= count-n messages, recreate the index */
#define MAIL_INDEX_MAX_OVERWRITE_NEG_SEQ_COUNT 10
{
const char *backup_path, *tmp_backup_path;
int ret;
/* we very much want to avoid creating a backup file that
hasn't been written to disk yet */
return -1;
}
}
return -1;
}
}
if (ret < 0) {
/* no dovecot.index file, ignore */
return 0;
}
return -1;
}
return -1;
}
return 0;
}
{
unsigned int base_size;
const char *path;
if (fd == -1)
return -1;
if (o_stream_nfinish(output) < 0) {
ret = -1;
}
"fdatasync()");
ret = -1;
}
}
ret = -1;
}
(void)mail_index_create_backup(index);
ret = -1;
}
if (ret < 0)
return ret;
}
{
return;
/* rotate the .log before writing index, so the index will point to
the latest log. */
if (want_rotate &&
struct mail_transaction_log_file *file =
}
}
if (!MAIL_INDEX_IS_IN_MEMORY(index)) {
if (mail_index_recreate(index) < 0) {
(void)mail_index_move_to_memory(index);
return;
}
}
}