[dovecot-cvs] dovecot/src/lib-index mail-custom-flags.c,1.21,1.22
cras at procontrol.fi
cras at procontrol.fi
Wed Jun 4 21:09:58 EEST 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv24587/lib-index
Modified Files:
mail-custom-flags.c
Log Message:
mbox with in-memory indexes don't have control_dir and doesn't need it, so
don't crash then.
Index: mail-custom-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-custom-flags.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-custom-flags.c 18 May 2003 12:56:14 -0000 1.21
+++ mail-custom-flags.c 4 Jun 2003 17:09:56 -0000 1.22
@@ -241,25 +241,34 @@
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;
More information about the dovecot-cvs
mailing list