dbox-sync-file.c revision d7bd88416567f07b56581a65e1cd46a42adb79c0
/* Copyright (c) 2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "dbox-storage.h"
#include "dbox-index.h"
#include "dbox-file.h"
#include "dbox-sync.h"
{
return -1;
}
return 0;
}
static void
const struct dbox_sync_file_entry *entry,
{
const struct mail_index_record *rec;
struct mail_keywords *keywords;
const char *old_value;
t_push();
/* flags */
/* keywords */
if (array_count(&keyword_indexes) > 0 ||
array_count(&keyword_indexes) == 0)) {
str_truncate(value, 0);
}
/* expunge state */
}
t_pop();
}
static int
const struct dbox_sync_file_entry *entry)
{
unsigned int i, count;
bool expunged;
int ret;
&file_id, &first_offset))
return 0;
for (;;) {
&physical_size)) <= 0)
break;
if (uid == 0) {
/* EOF */
break;
}
if (i < count) {
if (++i == count)
break;
}
}
/* this message gets expunged */
if (seq != 0)
continue;
}
/* non-expunged message. write it to output file. */
&output);
if (ret <= 0)
break;
}
/* write metadata */
(enum mail_flags)MAIL_INDEX_MAIL_FLAG_DIRTY);
}
if (ret <= 0) {
i_error("unlink(%s) failed: %m",
}
}
/* FIXME: rename out_file and add to index */
}
if (ret <= 0)
;
/* nothing exists in this file anymore */
} else {
ret = -1;
}
}
return ret;
}
static int
{
bool expunged;
int ret;
return 0;
if (ret <= 0)
return ret;
if (expunged) {
return 1;
}
if (ret <= 0) {
/* FIXME: handle ret=0 case by splitting the file */
return ret;
}
(enum mail_flags)MAIL_INDEX_MAIL_FLAG_DIRTY);
return 1;
}
static int
{
unsigned int i, count;
int ret;
} else {
}
for (i = 0; i < count; ) {
if (seq >= first_expunge_seq)
if (ret <= 0)
return ret;
}
i++;
}
return 1;
}
static void
const struct dbox_sync_file_entry *entry)
{
unsigned int count;
}
const struct dbox_sync_file_entry *entry)
{
struct dbox_index_record *rec;
enum dbox_index_file_status status;
int ret;
} else {
/* file doesn't exist, nothing to do */
return 1;
}
}
if (status == DBOX_INDEX_FILE_STATUS_SINGLE_MESSAGE &&
/* fast path to expunging the whole file */
if (dbox_sync_file_unlink(file) < 0)
ret = -1;
else {
ret = 1;
}
} else {
}
return ret;
}