From fc6a0f88601083a781d483f70d1baf5dbaac19aa Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 4 Jun 2003 20:09:56 +0300 Subject: [PATCH] mbox with in-memory indexes don't have control_dir and doesn't need it, so don't crash then. --HG-- branch : HEAD --- src/lib-index/mail-custom-flags.c | 35 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/lib-index/mail-custom-flags.c b/src/lib-index/mail-custom-flags.c index 4a8f1b36d0..a66bf886d1 100644 --- a/src/lib-index/mail-custom-flags.c +++ b/src/lib-index/mail-custom-flags.c @@ -241,25 +241,34 @@ int mail_custom_flags_open_or_create(struct mail_index *index) const char *path; int fd, readonly; - path = t_strconcat(index->control_dir, "/", - CUSTOM_FLAGS_FILE_NAME, NULL); readonly = index->mailbox_readonly; - fd = !index->mailbox_readonly ? - open(path, O_RDWR | O_CREAT, 0660) : open(path, O_RDONLY); - if (fd == -1) { - if (errno == EACCES) { - fd = open(path, O_RDONLY); - readonly = TRUE; - } - if (errno != EACCES && errno != ENOENT && !ENOSPACE(errno)) { - index_file_set_syscall_error(index, path, "open()"); - return FALSE; + + if (index->control_dir != NULL) { + path = t_strconcat(index->control_dir, "/", + CUSTOM_FLAGS_FILE_NAME, NULL); + fd = !readonly ? open(path, O_RDWR | O_CREAT, 0660) : + open(path, O_RDONLY); + if (fd == -1) { + if (errno == EACCES) { + fd = open(path, O_RDONLY); + readonly = TRUE; + } + if (errno != EACCES && errno != ENOENT && + !ENOSPACE(errno)) { + index_file_set_syscall_error(index, path, "open()"); + return FALSE; + } } + } else { + path = NULL; + fd = -1; } mcf = i_new(struct mail_custom_flags, 1); mcf->index = index; - mcf->filepath = i_strdup(path); + mcf->filepath = fd != -1 ? i_strdup(path) : + i_strdup_printf("(in-memory custom flags for %s)", + index->mailbox_path); mcf->fd = fd; mcf->noupdate = mcf->fd == -1 || readonly; -- 2.47.3