sdbox-sync-rebuild.c revision 9fc97c8aa8190df87624d214bcc5d0b5362bec93
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "index-rebuild.h"
#include "mail-cache.h"
#include "sdbox-storage.h"
#include "sdbox-file.h"
#include "sdbox-sync.h"
#include <stdlib.h>
#include <dirent.h>
{
/* if uidvalidity is set in the old index, use it */
if (uid_validity == 0)
}
static int
{
bool deleted;
int ret;
if (deleted)
return 0;
}
if (ret == 0) {
}
if (ret <= 0) {
if (ret < 0)
return -1;
return 0;
}
/* we were supposed to open the file in alt storage, but it
exists in primary storage as well. skip it to avoid adding
it twice. */
return 0;
}
T_BEGIN {
} T_END;
return 0;
}
static int
{
int ret;
strlen(SDBOX_MAIL_FILE_PREFIX)) != 0)
return 0;
i_warning("sdbox %s: Ignoring invalid filename %s",
return 0;
}
if (!primary)
return ret;
}
{
struct dirent *d;
int ret = 0;
if (!primary) {
/* alt directory doesn't exist, ignore */
return 0;
}
return -1;
}
"opendir(%s) failed: %m", path);
return -1;
}
do {
errno = 0;
break;
} while (ret >= 0);
if (errno != 0) {
"readdir(%s) failed: %m", path);
ret = -1;
}
"closedir(%s) failed: %m", path);
ret = -1;
}
return ret;
}
{
struct sdbox_index_header hdr;
if (++hdr.rebuild_count == 0)
/* mailbox is being reset. this gets written directly there */
}
static int
{
int ret = 0;
&alt_path) < 0)
return -1;
"sdbox: Rebuilding failed on path %s",
ret = -1;
"sdbox: Rebuilding failed on alt path %s",
alt_path);
ret = -1;
}
}
return ret;
}
{
struct index_rebuild_context *ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
struct sdbox_index_header hdr;
int ret;
hdr.rebuild_count != 0) {
/* already rebuilt by someone else */
return 0;
}
}
"sdbox %s: Alt storage not mounted, "
return -1;
}
if (ret < 0)
else
mbox->corrupted_rebuild_count = 0;
return ret;
}