From: Timo Sirainen Date: Fri, 29 Dec 2023 15:46:10 +0000 (-0500) Subject: lib-storage: mail_storage_create() - Add storage_r parameter X-Git-Tag: 2.4.1~1194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d70bc4831bb04cd48657cd7572c42520ce700d20;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail_storage_create() - Add storage_r parameter --- diff --git a/src/lib-storage/index/raw/raw-storage.c b/src/lib-storage/index/raw/raw-storage.c index b6447a86fe..e83bc91b2f 100644 --- a/src/lib-storage/index/raw/raw-storage.c +++ b/src/lib-storage/index/raw/raw-storage.c @@ -22,6 +22,7 @@ raw_storage_create_from_set(struct mail_storage_service_ctx *ctx, struct mail_user *user; struct mail_namespace *ns; struct mail_namespace_settings *ns_set; + struct mail_storage *storage; struct event *event; const char *error; @@ -74,7 +75,7 @@ raw_storage_create_from_set(struct mail_storage_service_ctx *ctx, ns->flags |= NAMESPACE_FLAG_NOQUOTA | NAMESPACE_FLAG_NOACL; ns->set = ns_set; - if (mail_storage_create(ns, user->event, 0, &error) < 0) + if (mail_storage_create(ns, user->event, 0, &storage, &error) < 0) i_fatal("Couldn't create internal raw storage: %s", error); if (mail_namespaces_init_finish(ns, &error) < 0) i_fatal("Couldn't create internal raw namespace: %s", error); diff --git a/src/lib-storage/index/shared/shared-storage.c b/src/lib-storage/index/shared/shared-storage.c index ae6876db7e..5efa572623 100644 --- a/src/lib-storage/index/shared/shared-storage.c +++ b/src/lib-storage/index/shared/shared-storage.c @@ -421,10 +421,12 @@ shared_mail_user_init(struct mail_storage *_storage, return -1; } + struct mail_storage *new_storage; new_storage_flags = _storage->flags & ENUM_NEGATE(MAIL_STORAGE_FLAG_SHARED_DYNAMIC); new_storage_flags |= MAIL_STORAGE_FLAG_NO_AUTOVERIFY; - if (mail_storage_create(new_ns, set_event, new_storage_flags, &error) < 0) { + if (mail_storage_create(new_ns, set_event, new_storage_flags, + &new_storage, &error) < 0) { mailbox_list_set_critical(ns->list, "Namespace %s: %s", new_ns->prefix, error); /* owner gets freed by namespace deinit */ diff --git a/src/lib-storage/mail-namespace.c b/src/lib-storage/mail-namespace.c index d1bc9b2599..604ea74886 100644 --- a/src/lib-storage/mail-namespace.c +++ b/src/lib-storage/mail-namespace.c @@ -132,6 +132,7 @@ int mail_namespaces_init_add(struct mail_user *user, struct event *set_event, { enum mail_storage_flags flags = 0; struct mail_namespace *ns; + struct mail_storage *storage; const char *error; int ret; @@ -163,7 +164,7 @@ int mail_namespaces_init_add(struct mail_user *user, struct event *set_event, ns->flags |= NAMESPACE_FLAG_NOQUOTA | NAMESPACE_FLAG_NOACL; } - if (mail_storage_create(ns, set_event, flags, &error) < 0) { + if (mail_storage_create(ns, set_event, flags, &storage, &error) < 0) { *error_r = t_strdup_printf("Namespace %s: %s", ns->set->name, error); mail_namespace_free(ns); @@ -505,6 +506,7 @@ mail_namespaces_init_location_full(struct mail_user *user, { struct mail_namespace_settings *inbox_set; struct mail_namespace *ns; + struct mail_storage *storage; int ret; inbox_set = p_new(user->pool, struct mail_namespace_settings, 1); @@ -536,7 +538,7 @@ mail_namespaces_init_location_full(struct mail_user *user, SETTINGS_OVERRIDE_TYPE_CODE); } - if (mail_storage_create(ns, set_event, 0, error_r) < 0) { + if (mail_storage_create(ns, set_event, 0, &storage, error_r) < 0) { mail_namespace_free(ns); return -1; } diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 81c084c1d7..09d0620b03 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -569,13 +569,13 @@ mail_storage_create_real(struct mail_namespace *ns, struct event *set_event, } int mail_storage_create(struct mail_namespace *ns, struct event *set_event, - enum mail_storage_flags flags, const char **error_r) + enum mail_storage_flags flags, + struct mail_storage **storage_r, const char **error_r) { - struct mail_storage *storage; int ret; T_BEGIN { ret = mail_storage_create_real(ns, set_event, flags, - &storage, error_r); + storage_r, error_r); } T_END_PASS_STR_IF(ret < 0, error_r); return ret; } diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index adfabfbadd..af7e71b33d 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -491,7 +491,8 @@ struct mail_storage *mail_storage_find_class(const char *name); /* Create a storage for the namespace. */ int mail_storage_create(struct mail_namespace *ns, struct event *event, - enum mail_storage_flags flags, const char **error_r); + enum mail_storage_flags flags, + struct mail_storage **storage_r, const char **error_r); void mail_storage_unref(struct mail_storage **storage); /* Returns the mail storage settings. */