-I$(top_srcdir)/src/lib-master \
-I$(top_srcdir)/src/lib-settings \
-I$(top_srcdir)/src/lib-mail \
+ -I$(top_srcdir)/src/lib-index \
-I$(top_srcdir)/src/lib-storage \
-DPKG_RUNDIR=\""$(rundir)"\"
#include "master-service.h"
#include "master-service-settings.h"
#include "mail-namespace.h"
-#include "mail-storage.h"
+#include "mail-storage-private.h"
#include "mail-storage-service.h"
#include "mail-search-build.h"
#include "master-connection.h"
return -1;
}
- path = mailbox_list_get_path(ns->list, mailbox,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ box = mailbox_alloc(ns->list, mailbox, 0);
+ path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
if (*path == '\0') {
i_info("Indexes disabled for Mailbox %s, skipping", mailbox);
+ mailbox_free(&box);
return 0;
}
-
- box = mailbox_alloc(ns->list, mailbox, 0);
+
if (max_recent_msgs != 0) {
/* index only if there aren't too many recent messages.
don't bother syncing the mailbox, that alone can take a
{
const char *dir;
- dir = mailbox_list_get_path(mail->box->list, mail->box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ dir = mailbox_get_path(mail->box);
return t_strdup_printf("%s/%u.", dir, mail->uid);
}
{
const char *dir;
- dir = mailbox_list_get_path(ctx->mbox->box.list, ctx->mbox->box.name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ dir = mailbox_get_path(&ctx->mbox->box);
return t_strdup_printf("%s/%s.%u", dir, ctx->tmp_basename, num);
}
&_t->changes->saved_uids);
_t->changes->uid_validity = ctx->sync_ctx->uid_validity;
- dir = mailbox_list_get_path(ctx->mbox->box.list, ctx->mbox->box.name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ dir = mailbox_get_path(&ctx->mbox->box);
src_path = t_str_new(256);
str_printfa(src_path, "%s/%s.", dir, ctx->tmp_basename);
static string_t *cydir_get_path_prefix(struct cydir_mailbox *mbox)
{
string_t *path = str_new(default_pool, 256);
- const char *dir;
- dir = mailbox_list_get_path(mbox->box.list, mbox->box.name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
- str_append(path, dir);
+ str_append(path, mailbox_get_path(&mbox->box));
str_append_c(path, '/');
return path;
}
if (box->notify_callback == NULL)
index_mailbox_check_remove_all(box);
else {
- dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
path = t_strdup_printf("%s/"DBOX_INDEX_PREFIX".log", dir);
index_mailbox_check_add(box, path);
}
/* if alt path already exists and contains files, rebuild storage so
that we don't start overwriting files. */
- alt_path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
+ alt_path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
if (alt_path != NULL && stat(alt_path, &st) == 0) {
ret = dir_is_empty(box->storage, alt_path);
if (ret < 0)
file->file.primary_path =
i_strdup_printf("%s/%s", mailbox_get_path(box), fname);
- alt_path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
+ alt_path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
if (alt_path != NULL)
file->file.alt_path = i_strdup_printf("%s/%s", alt_path, fname);
}
int ret = 0;
path = mailbox_get_path(ctx->box);
- alt_path = mailbox_list_get_path(ctx->box->list, ctx->box->name,
- MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
+ alt_path = mailbox_get_path_to(ctx->box,
+ MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX);
sdbox_sync_set_uidvalidity(ctx);
if (sdbox_sync_index_rebuild_dir(ctx, path, TRUE) < 0) {
mail_cache_reset(box->cache);
/* if backup index file exists, try to use it */
- index_dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ index_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
backup_path = t_strconcat(box->index_prefix, "/.backup", NULL);
ctx->backup_index = mail_index_alloc(index_dir, backup_path);
{
const char *index_dir, *mailbox_path;
- mailbox_path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ mailbox_path = mailbox_get_path(box);
index_dir = (box->flags & MAILBOX_FLAG_NO_INDEX_FILES) != 0 ? "" :
- mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
if (*index_dir == '\0')
index_dir = NULL;
const char *path, *path2;
/* see if it's selectable */
- path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ path = mailbox_get_path(box);
if (subdir != NULL)
path = t_strconcat(path, "/", subdir, NULL);
if (stat(path, &st) == 0) {
}
/* see if it's non-selectable */
- path2 = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_DIR);
+ path2 = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_DIR);
if (strcmp(path, path2) != 0 &&
stat(path2, &st) == 0) {
*existence_r = MAILBOX_EXISTENCE_NOSELECT;
if (box->index_pvt != NULL)
return 1;
- index_dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE);
+ index_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE);
if (index_dir == NULL) {
/* no private indexes */
return 0;
return 1;
}
- dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
path = t_strconcat(dir, "/", box->index_prefix, ".log", NULL);
if (stat(path, &st) < 0) {
if (errno == ENOENT)
return;
old_rec = data;
- dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
path = t_strconcat(dir, "/", box->index_prefix, ".log", NULL);
if (stat(path, &st) < 0) {
mail_storage_set_critical(box->storage,
struct maildir_keywords *mk;
const char *dir;
- dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_CONTROL);
+ dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL);
mk = i_new(struct maildir_keywords, 1);
mk->storage = box->storage;
return 1;
}
- root_dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ root_dir = mailbox_get_path(box);
/* check if new/ changed */
new_dir = t_strconcat(root_dir, "/new", NULL);
return 1;
}
- index_storage_lock_notify_reset(uidlist->box);
+ index_storage_lock_notify_reset(box);
- control_dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_CONTROL);
+ control_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL);
path = t_strconcat(control_dir, "/" MAILDIR_UIDLIST_NAME, NULL);
for (i = 0;; i++) {
struct maildir_uidlist *uidlist;
const char *control_dir;
- control_dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_CONTROL);
+ control_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL);
uidlist = i_new(struct maildir_uidlist, 1);
uidlist->box = box;
maildir_uidlist_records_drop_expunges(uidlist);
- control_dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_CONTROL);
+ control_dir = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL);
temp_path = t_strconcat(control_dir,
"/" MAILDIR_UIDLIST_NAME ".tmp", NULL);
{
struct maildir_uidlist *uidlist = ctx->uidlist;
struct maildir_uidlist_rec *rec, *old_rec;
- const char *p, *dir;
+ const char *p;
*rec_r = NULL;
return -1;
for (p = filename; *p != '\0'; p++) {
if (*p == 13 || *p == 10) {
- struct mailbox *box = uidlist->box;
-
- dir = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
i_warning("Maildir %s: Ignoring a file with #0x%x: %s",
- dir, *p, filename);
+ mailbox_get_path(uidlist->box), *p, filename);
return 1;
}
}
"/", subdirs[i], NULL);
}
types[i] = MAILBOX_LIST_PATH_TYPE_CONTROL;
- dirs[i++] = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_CONTROL);
+ dirs[i++] = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_CONTROL);
types[i] = MAILBOX_LIST_PATH_TYPE_INDEX;
- dirs[i++] = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ dirs[i++] = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
i_assert(i == N_ELEMENTS(dirs));
for (i = 0; i < N_ELEMENTS(dirs); i++) {
const char *inbox_path;
int fd;
- inbox_path = mailbox_list_get_path(box->list, "INBOX",
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ inbox_path = mailbox_get_path(box);
fd = open(inbox_path, O_RDWR | O_CREAT | O_EXCL, 0660);
if (fd == -1 && errno == EACCES) {
int mailbox_mark_index_deleted(struct mailbox *box, bool del);
/* Easy wrapper for getting mailbox's MAILBOX_LIST_PATH_TYPE_MAILBOX */
const char *mailbox_get_path(struct mailbox *box) ATTR_PURE;
+/* Returns path to specified type of files in mailbox. */
+const char *
+mailbox_get_path_to(struct mailbox *box, enum mailbox_list_path_type type);
/* Get mailbox permissions. */
const struct mailbox_permissions *mailbox_get_permissions(struct mailbox *box);
/* Force permissions to be refreshed on next lookup */
box->mailbox_deleted = TRUE;
}
+const char *
+mailbox_get_path_to(struct mailbox *box, enum mailbox_list_path_type type)
+{
+ return mailbox_list_get_path(box->list, box->name, type);
+}
+
const char *mailbox_get_path(struct mailbox *box)
{
const char *path;
if (box->_path == NULL) {
- path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX);
box->_path = p_strdup(box->pool, path);
}
return box->_path;
box = mailbox_alloc(ns->list, mailbox,
MAILBOX_FLAG_READONLY | MAILBOX_FLAG_IGNORE_ACLS);
if (mailbox_open(box) < 0) {
- path = mailbox_list_get_path(ns->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ path = mailbox_get_path(box);
errstr = mail_storage_get_last_error(box->storage, &error);
doveadm_mail_failed_error(ctx, error);
if (error != MAIL_ERROR_NOTFOUND ||
perm = mailbox_get_permissions(box);
storage = mailbox_get_storage(box);
- path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_INDEX);
+ path = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX);
i_assert(*path != '\0'); /* fts already checked this */
mailbox_get_open_status(box, STATUS_UIDVALIDITY, &status);
if (root->storage_mount_path == NULL)
return TRUE;
- mailbox_path = mailbox_list_get_path(box->list, box->name,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ mailbox_path = mailbox_get_path(box);
if (stat(mailbox_path, &mst) < 0) {
if (errno != ENOENT)
i_error("stat(%s) failed: %m", mailbox_path);