]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Don't give an error if "storage" directory is missing.
authorTimo Sirainen <tss@iki.fi>
Mon, 23 Mar 2009 22:26:05 +0000 (18:26 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 23 Mar 2009 22:26:05 +0000 (18:26 -0400)
--HG--
branch : HEAD

src/lib-storage/index/dbox/dbox-mail.c
src/lib-storage/index/dbox/dbox-map.c
src/lib-storage/index/dbox/dbox-map.h
src/lib-storage/index/dbox/dbox-storage-rebuild.c

index 9e3af8ca91c9c3426a65d66bb3f11248a92bc067..fae1673c2004f92627f1f82c8623815c1362afa0 100644 (file)
@@ -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);
index 7a77d0c37233b176c8e2b3444ab654fe79327457..04a958b9db271eb0b8dcd580e44ac305d8f19c5e 100644 (file)
@@ -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 */
index 1069f835482fcba74e3986b7357fc56b7a28c65e..e226130c0f3fe432e7e1ed82643a82b69e4f655a 100644 (file)
@@ -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. */
index 8c2b56e697f6511c59c07e40f2c4c7228aa168fc..b0abcba2ef665acc34e125c4517b059f7df8b1da 100644 (file)
@@ -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