From: Timo Sirainen Date: Mon, 23 Mar 2009 22:26:05 +0000 (-0400) Subject: dbox: Don't give an error if "storage" directory is missing. X-Git-Tag: 2.0.alpha1~1038^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2411e21dbbde1821ae6c583321c4bab3e9d1db46;p=thirdparty%2Fdovecot%2Fcore.git dbox: Don't give an error if "storage" directory is missing. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/dbox/dbox-mail.c b/src/lib-storage/index/dbox/dbox-mail.c index 9e3af8ca91..fae1673c20 100644 --- a/src/lib-storage/index/dbox/dbox-mail.c +++ b/src/lib-storage/index/dbox/dbox-mail.c @@ -74,7 +74,7 @@ int dbox_mail_lookup(struct dbox_mailbox *mbox, struct mail_index_view *view, hdr = data; mbox->map_uid_validity = hdr->map_uid_validity; } - if (dbox_map_open(mbox->storage->map) < 0) + if (dbox_map_open(mbox->storage->map, TRUE) < 0) return -1; cur_map_uid_validity = dbox_map_get_uid_validity(mbox->storage->map); diff --git a/src/lib-storage/index/dbox/dbox-map.c b/src/lib-storage/index/dbox/dbox-map.c index 7a77d0c372..04a958b9db 100644 --- a/src/lib-storage/index/dbox/dbox-map.c +++ b/src/lib-storage/index/dbox/dbox-map.c @@ -59,7 +59,7 @@ void dbox_map_deinit(struct dbox_map **_map) i_free(map); } -int dbox_map_open(struct dbox_map *map) +int dbox_map_open(struct dbox_map *map, bool create_missing) { struct mail_storage *storage = &map->storage->storage; enum mail_index_open_flags open_flags; @@ -72,13 +72,18 @@ int dbox_map_open(struct dbox_map *map) open_flags = MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY | index_storage_get_index_open_flags(storage); - ret = mail_index_open_or_create(map->index, open_flags, - storage->lock_method); + if (create_missing) + open_flags |= MAIL_INDEX_OPEN_FLAG_CREATE; + ret = mail_index_open(map->index, open_flags, storage->lock_method); if (ret < 0) { mail_storage_set_internal_error(storage); mail_index_reset_error(map->index); return -1; } + if (ret == 0) { + /* index not found - for now just return failure */ + return -1; + } map->view = mail_index_view_open(map->index); return 0; @@ -149,7 +154,7 @@ int dbox_map_lookup(struct dbox_map *map, uint32_t map_uid, uoff_t size; int ret; - if (dbox_map_open(map) < 0) + if (dbox_map_open(map, TRUE) < 0) return -1; if ((ret = dbox_map_get_seq(map, map_uid, &seq)) <= 0) @@ -228,7 +233,7 @@ const ARRAY_TYPE(seq_range) *dbox_map_get_zero_ref_files(struct dbox_map *map) else i_array_init(&map->ref0_file_ids, 64); - if (dbox_map_open(map) < 0) { + if (dbox_map_open(map, FALSE) < 0) { /* some internal error */ return &map->ref0_file_ids; } @@ -420,7 +425,7 @@ dbox_map_append_begin_storage(struct dbox_storage *storage) i_array_init(&ctx->files, 64); i_array_init(&ctx->appends, 128); - if (dbox_map_open(ctx->map) < 0) + if (dbox_map_open(ctx->map, TRUE) < 0) ctx->failed = TRUE; /* refresh the map so we can try appending to the latest files */ diff --git a/src/lib-storage/index/dbox/dbox-map.h b/src/lib-storage/index/dbox/dbox-map.h index 1069f83548..e226130c0f 100644 --- a/src/lib-storage/index/dbox/dbox-map.h +++ b/src/lib-storage/index/dbox/dbox-map.h @@ -31,7 +31,7 @@ void dbox_map_deinit(struct dbox_map **map); /* Open the map. This is done automatically for most operations. Returns 0 if ok, -1 if error. */ -int dbox_map_open(struct dbox_map *map); +int dbox_map_open(struct dbox_map *map, bool create_missing); /* Look up file_id and offset for given map UID. Returns 1 if ok, 0 if UID is already expunged, -1 if error. */ diff --git a/src/lib-storage/index/dbox/dbox-storage-rebuild.c b/src/lib-storage/index/dbox/dbox-storage-rebuild.c index 8c2b56e697..b0abcba2ef 100644 --- a/src/lib-storage/index/dbox/dbox-storage-rebuild.c +++ b/src/lib-storage/index/dbox/dbox-storage-rebuild.c @@ -632,7 +632,7 @@ static int dbox_storage_rebuild_scan(struct dbox_storage_rebuild_context *ctx) uint32_t uid_validity; int ret = 0; - if (dbox_map_open(ctx->storage->map) < 0) + if (dbox_map_open(ctx->storage->map, TRUE) < 0) return -1; /* begin by locking the map, so that other processes can't try to