dovecot-2.0: mdbox: Rebuilding storage ignored mails in alt stor...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Mar 16 15:20:17 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/cc0a8b0347f9
changeset: 10917:cc0a8b0347f9
user: Timo Sirainen <tss at iki.fi>
date: Tue Mar 16 15:20:15 2010 +0200
description:
mdbox: Rebuilding storage ignored mails in alt storage.
diffstat:
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 90 ++++++++++-------
1 files changed, 54 insertions(+), 36 deletions(-)
diffs (113 lines):
diff -r 1630026e8803 -r cc0a8b0347f9 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Mar 16 14:53:19 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Mar 16 15:20:15 2010 +0200
@@ -735,13 +735,60 @@
return 0;
}
-static int mdbox_storage_rebuild_scan(struct mdbox_storage_rebuild_context *ctx)
+static int
+mdbox_storage_rebuild_scan_dir(struct mdbox_storage_rebuild_context *ctx,
+ const char *storage_dir, bool alt)
{
- const struct mail_index_header *hdr;
DIR *dir;
struct dirent *d;
string_t *path;
unsigned int dir_len;
+ int ret = 0;
+
+ dir = opendir(storage_dir);
+ if (dir == NULL) {
+ if (alt && errno == ENOENT)
+ return 0;
+
+ mail_storage_set_critical(&ctx->storage->storage.storage,
+ "opendir(%s) failed: %m", storage_dir);
+ return -1;
+ }
+ path = t_str_new(256);
+ str_append(path, storage_dir);
+ str_append_c(path, '/');
+ dir_len = str_len(path);
+
+ for (errno = 0; (d = readdir(dir)) != NULL; errno = 0) {
+ if (strncmp(d->d_name, MDBOX_MAIL_FILE_PREFIX,
+ strlen(MDBOX_MAIL_FILE_PREFIX)) == 0) {
+ str_truncate(path, dir_len);
+ str_append(path, d->d_name);
+ T_BEGIN {
+ ret = rebuild_add_file(ctx, str_c(path));
+ } T_END;
+ if (ret < 0) {
+ ret = -1;
+ break;
+ }
+ }
+ }
+ if (ret == 0 && errno != 0) {
+ mail_storage_set_critical(&ctx->storage->storage.storage,
+ "readdir(%s) failed: %m", storage_dir);
+ ret = -1;
+ }
+ if (closedir(dir) < 0) {
+ mail_storage_set_critical(&ctx->storage->storage.storage,
+ "closedir(%s) failed: %m", storage_dir);
+ ret = -1;
+ }
+ return ret;
+}
+
+static int mdbox_storage_rebuild_scan(struct mdbox_storage_rebuild_context *ctx)
+{
+ const struct mail_index_header *hdr;
uint32_t uid_validity;
int ret = 0;
@@ -767,41 +814,12 @@
&uid_validity, sizeof(uid_validity), TRUE);
}
- dir = opendir(ctx->storage->storage_dir);
- if (dir == NULL) {
- mail_storage_set_critical(&ctx->storage->storage.storage,
- "opendir(%s) failed: %m", ctx->storage->storage_dir);
+ if (mdbox_storage_rebuild_scan_dir(ctx, ctx->storage->storage_dir,
+ FALSE) < 0)
return -1;
- }
- path = t_str_new(256);
- str_append(path, ctx->storage->storage_dir);
- str_append_c(path, '/');
- dir_len = str_len(path);
-
- for (errno = 0; (d = readdir(dir)) != NULL; errno = 0) {
- if (strncmp(d->d_name, MDBOX_MAIL_FILE_PREFIX,
- strlen(MDBOX_MAIL_FILE_PREFIX)) == 0) {
- str_truncate(path, dir_len);
- str_append(path, d->d_name);
- T_BEGIN {
- ret = rebuild_add_file(ctx, str_c(path));
- } T_END;
- if (ret < 0) {
- ret = -1;
- break;
- }
- }
- }
- if (ret == 0 && errno != 0) {
- mail_storage_set_critical(&ctx->storage->storage.storage,
- "readdir(%s) failed: %m", ctx->storage->storage_dir);
- ret = -1;
- }
- if (closedir(dir) < 0) {
- mail_storage_set_critical(&ctx->storage->storage.storage,
- "closedir(%s) failed: %m", ctx->storage->storage_dir);
- ret = -1;
- }
+ if (mdbox_storage_rebuild_scan_dir(ctx, ctx->storage->alt_storage_dir,
+ TRUE) < 0)
+ return -1;
if (ret < 0 ||
rebuild_apply_map(ctx) < 0 ||
More information about the dovecot-cvs
mailing list