From: Markus Valentin Date: Thu, 22 Jun 2023 08:00:12 +0000 (+0200) Subject: dbox: dbox_mailbox_check_existence() - Return 1 if a separate INDEX dir has an existi... X-Git-Tag: 2.4.0~2630 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377fa8ab6b7bde09e290d6b0dbb5033c96064b5d;p=thirdparty%2Fdovecot%2Fcore.git dbox: dbox_mailbox_check_existence() - Return 1 if a separate INDEX dir has an existing index This allows taking actions if the separate INDEX dir does not have an existing index file for a mailbox. --- diff --git a/src/lib-storage/index/dbox-common/dbox-storage.c b/src/lib-storage/index/dbox-common/dbox-storage.c index 176f663478..c303be12ce 100644 --- a/src/lib-storage/index/dbox-common/dbox-storage.c +++ b/src/lib-storage/index/dbox-common/dbox-storage.c @@ -236,6 +236,7 @@ int dbox_mailbox_check_existence(struct mailbox *box) const char *index_path, *box_path = mailbox_get_path(box); struct stat st; int ret = -1; + bool has_log_in_index_dir = FALSE; if (box->list->set.index_dir != NULL) { /* Just because the index directory exists, it doesn't mean @@ -253,6 +254,8 @@ int dbox_mailbox_check_existence(struct mailbox *box) index_path = t_strconcat(index_path, "/", box->index_prefix, ".log", NULL); ret = stat(index_path, &st); + if (ret == 0) + has_log_in_index_dir = TRUE; } if (ret < 0) { ret = stat(box_path, &st); @@ -264,6 +267,8 @@ int dbox_mailbox_check_existence(struct mailbox *box) } if (ret == 0) { + if (has_log_in_index_dir) + return 1; return 0; } else if (errno == ENOENT || errno == ENAMETOOLONG) { mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,