dbox-sync-rebuild.c revision 4f44284b96302c0a18203e2ac1243aeb193c6840
/* Copyright (c) 2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "dbox-storage.h"
#include "../maildir/maildir-uidlist.h"
#include "../maildir/maildir-keywords.h"
#include "dbox-index.h"
#include "dbox-file.h"
#include "dbox-sync.h"
#include <stdlib.h>
#include <dirent.h>
struct dbox_sync_rebuild_context {
struct dbox_mailbox *mbox;
struct dbox_index_append_context *append_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
struct maildir_uidlist *maildir_uidlist;
struct maildir_keywords *mk;
ARRAY_DEFINE(maildir_new_files, char *);
unsigned int cache_used:1;
};
{
&uid_validity) < 0)
return -1;
return 0;
}
static void
{
struct mail_index_map *map;
const void *data;
bool expunged;
return;
if (expunged)
return;
&reset_id))
return;
if (!ctx->cache_used) {
/* set reset id */
}
}
}
static void
{
const struct mail_index_record *rec;
struct mail_keywords *kw;
/* copy flags */
/* copy keywords */
}
static void
{
const char *value;
struct mail_keywords *keywords;
enum mail_flags flags = 0;
unsigned int i;
/* the message exists in the old index.
copy the metadata from it. */
return;
}
for (i = 0; value[i] != '\0'; i++) {
flags |= dbox_mail_flags_map[i];
}
}
t_push();
keywords);
t_pop();
}
}
{
const char *path;
bool expunged;
int ret;
if (ret <= 0) {
if (ret < 0)
return -1;
/* EOF */
return 0;
}
return 0;
}
return 0;
}
if (file->maildir_file) {
&uid)) {
if (ctx->maildir_new_uid == 0) {
/* not in uidlist, give it an uid later */
&fname, 1);
return 0;
}
}
}
if (ret <= 0) {
if (ret < 0)
return -1;
return 0;
}
if (!expunged) {
}
return 1;
}
static int
{
unsigned long uid;
char *p;
int ret;
i_warning("dbox %s: Ignoring invalid filename %s",
return 0;
}
return ret;
}
static int
{
/* FIXME */
return 0;
}
static int
const char *fname)
{
int ret;
return -1;
}
return ret < 0 ? -1 : 0;
}
{
struct dirent *d;
int ret = 0;
return -1;
}
"opendir(%s) failed: %m", path);
return -1;
}
errno = 0;
t_push();
sizeof(DBOX_MAIL_FILE_UID_PREFIX)-1) == 0)
sizeof(DBOX_MAIL_FILE_MULTI_PREFIX)-1) == 0)
t_pop();
}
if (errno != 0) {
"readdir(%s) failed: %m", path);
ret = -1;
}
"closedir(%s) failed: %m", path);
ret = -1;
}
return ret;
}
{
struct mail_index_view *trans_view;
const struct mail_index_header *hdr;
char *const *fnames;
unsigned int i, count;
int ret = 0;
if (count == 0)
return 0;
/* try to give them UIDs beginning from uidlist's next_uid */
for (i = 0; i < count; i++) {
break;
}
if (i == count)
else {
}
t_push();
t_pop();
}
return ret;
}
{
if (dbox_sync_set_uidvalidity(ctx) < 0)
return -1;
return -1;
FALSE) < 0)
return -1;
}
/* finally give UIDs to newly seen maildir files */
return dbox_sync_new_maildir(ctx);
}
{
struct dbox_mail_index_record rec;
unsigned int i, count;
for (i = 0; i < count; i++) {
if (!files[i]->maildir_file)
continue;
}
}
{
struct dbox_sync_rebuild_context ctx;
char **fnames;
unsigned int i, count;
int ret;
else {
if (ret == 0) {
}
}
for (i = 0; i < count; i++)
if (ret == 0)
else
return ret;
}