annotate src/lib-storage/index/dbox/dbox-storage.c @ 5618:5ea33dbddbae HEAD

Moved index directory creation code to index_storage_alloc().
author Timo Sirainen <tss@iki.fi>
date Sun, 13 May 2007 21:28:41 +0300
parents f717fb4b31c0
children 1d73153584d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
1 /* Copyright (C) 2005-2007 Timo Sirainen */
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
4 #include "array.h"
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
5 #include "ioloop.h"
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "mkdir-parents.h"
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "unlink-directory.h"
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
8 #include "index-mail.h"
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 #include "mail-copy.h"
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 #include "dbox-uidlist.h"
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 #include "dbox-sync.h"
4203
4141aae720fe Fixed memory leaks
Timo Sirainen <tss@iki.fi>
parents: 4196
diff changeset
12 #include "dbox-file.h"
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 #include "dbox-storage.h"
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 #include <stdio.h>
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 #include <stdlib.h>
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 #include <unistd.h>
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 #include <sys/stat.h>
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 #define CREATE_MODE 0770 /* umask() should limit it more */
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
22 /* How often to touch the uidlist lock file when using KEEP_LOCKED flag */
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
23 #define DBOX_LOCK_TOUCH_MSECS (10*1000)
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
24
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
25 #define DBOX_LIST_CONTEXT(obj) \
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
26 MODULE_CONTEXT(obj, dbox_mailbox_list_module)
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
27
4969
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
28 const struct dotlock_settings default_uidlist_dotlock_set = {
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
29 MEMBER(temp_prefix) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
30 MEMBER(lock_suffix) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
31
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
32 MEMBER(timeout) 120,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
33 MEMBER(stale_timeout) 60,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
34
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
35 MEMBER(callback) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
36 MEMBER(context) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
37
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
38 MEMBER(use_excl_lock) FALSE
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
39 };
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
40
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
41 const struct dotlock_settings default_file_dotlock_set = {
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
42 MEMBER(temp_prefix) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
43 MEMBER(lock_suffix) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
44
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
45 MEMBER(timeout) 120,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
46 MEMBER(stale_timeout) 60,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
47
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
48 MEMBER(callback) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
49 MEMBER(context) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
50
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
51 MEMBER(use_excl_lock) FALSE
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
52 };
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
53
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
54 static const struct dotlock_settings default_new_file_dotlock_set = {
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
55 MEMBER(temp_prefix) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
56 MEMBER(lock_suffix) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
57
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
58 MEMBER(timeout) 60,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
59 MEMBER(stale_timeout) 30,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
60
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
61 MEMBER(callback) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
62 MEMBER(context) NULL,
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
63
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
64 MEMBER(use_excl_lock) FALSE
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
65 };
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
66
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
67 extern struct mail_storage dbox_storage;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
68 extern struct mailbox dbox_mailbox;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
69
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
70 static MODULE_CONTEXT_DEFINE_INIT(dbox_mailbox_list_module,
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
71 &mailbox_list_module_register);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
72
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
73 static int
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
74 dbox_list_delete_mailbox(struct mailbox_list *list, const char *name);
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
75 static int dbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
76 const char *dir, const char *fname,
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
77 enum mailbox_list_file_type type,
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
78 enum mailbox_info_flags *flags);
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
79
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
80 static bool
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
81 dbox_storage_is_valid_existing_name(struct mailbox_list *list, const char *name)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
82 {
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
83 struct dbox_storage *storage = DBOX_LIST_CONTEXT(list);
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
84 const char *p;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
85
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
86 if (!storage->list_module_ctx.super.is_valid_existing_name(list, name))
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
87 return FALSE;
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
88
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
89 /* Don't allow the mailbox name to end in dbox-Mails */
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
90 p = strrchr(name, '/');
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
91 if (p != NULL)
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
92 name = p + 1;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
93 return strcmp(name, DBOX_MAILDIR_NAME) != 0;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
94 }
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
95
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
96 static bool
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
97 dbox_storage_is_valid_create_name(struct mailbox_list *list, const char *name)
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
98 {
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
99 struct dbox_storage *storage = DBOX_LIST_CONTEXT(list);
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
100 const char *const *tmp;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
101 bool ret = TRUE;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
102
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
103 if (!storage->list_module_ctx.super.is_valid_create_name(list, name))
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
104 return FALSE;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
105
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
106 /* Don't allow creating mailboxes under dbox-Mails */
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
107 t_push();
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
108 for (tmp = t_strsplit(name, "/"); *tmp != NULL; tmp++) {
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
109 if (strcmp(*tmp, DBOX_MAILDIR_NAME) == 0) {
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
110 ret = FALSE;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
111 break;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
112 }
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
113 }
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
114 t_pop();
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
115 return ret;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
116 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
117
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
118 static int
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
119 dbox_get_list_settings(struct mailbox_list_settings *list_set,
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
120 const char *data, enum mail_storage_flags flags)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121 {
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3845
diff changeset
122 bool debug = (flags & MAIL_STORAGE_FLAG_DEBUG) != 0;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
123 const char *p;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124 size_t len;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
125
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
126 memset(list_set, 0, sizeof(*list_set));
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
127 list_set->subscription_fname = DBOX_SUBSCRIPTION_FILE_NAME;
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
128 list_set->maildir_name = DBOX_MAILDIR_NAME;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
129
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
130 if (data == NULL || *data == '\0') {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
131 /* we won't do any guessing for this format. */
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
132 if (debug)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 i_info("dbox: mailbox location not given");
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
134 return -1;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
135 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
136
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 /* <root dir> [:INDEX=<dir>] */
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
138 if (debug)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
139 i_info("dbox: data=%s", data);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
140 p = strchr(data, ':');
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
141 if (p == NULL)
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
142 list_set->root_dir = data;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
143 else {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
144 list_set->root_dir = t_strdup_until(data, p);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
145
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
146 do {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
147 p++;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
148 if (strncmp(p, "INDEX=", 6) == 0)
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
149 list_set->index_dir = t_strcut(p+6, ':');
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
150 p = strchr(p, ':');
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
151 } while (p != NULL);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
152 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
153
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
154 /* strip trailing '/' */
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
155 len = strlen(list_set->root_dir);
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
156 if (list_set->root_dir[len-1] == '/')
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
157 list_set->root_dir = t_strndup(list_set->root_dir, len-1);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
158
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
159 if (list_set->index_dir != NULL &&
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
160 strcmp(list_set->index_dir, "MEMORY") == 0)
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
161 list_set->index_dir = "";
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
162 return 0;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
163 }
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
164
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
165 static struct mail_storage *dbox_alloc(void)
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
166 {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
167 struct dbox_storage *storage;
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
168 pool_t pool;
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
169
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
170 pool = pool_alloconly_create("dbox storage", 512+256);
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
171 storage = p_new(pool, struct dbox_storage, 1);
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
172 storage->storage = dbox_storage;
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
173 storage->storage.pool = pool;
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
174
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
175 return &storage->storage;
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
176 }
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
177
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
178 static int dbox_create(struct mail_storage *_storage, const char *data)
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
179 {
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
180 struct dbox_storage *storage = (struct dbox_storage *)_storage;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
181 struct mailbox_list_settings list_set;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
182 struct mailbox_list *list;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
183 const char *error;
4859
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
184 struct stat st;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
185
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
186 if (dbox_get_list_settings(&list_set, data, _storage->flags) < 0)
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
187 return -1;
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
188 list_set.mail_storage_flags = &_storage->flags;
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
189 list_set.lock_method = &_storage->lock_method;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
190
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
191 if ((_storage->flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) != 0) {
4859
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
192 if (stat(list_set.root_dir, &st) < 0) {
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
193 if (errno != ENOENT) {
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
194 i_error("stat(%s) failed: %m",
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
195 list_set.root_dir);
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
196 }
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
197 return -1;
4859
92c0994a1fcf Added MAIL_STORAGE_FLAG_NO_AUTOCREATE flag which silently fails storage
Timo Sirainen <tss@iki.fi>
parents: 4853
diff changeset
198 }
5499
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
199 } else {
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
200 if (mkdir_parents(list_set.root_dir, CREATE_MODE) < 0 &&
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
201 errno != EEXIST) {
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
202 i_error("mkdir_parents(%s) failed: %m",
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
203 list_set.root_dir);
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
204 return -1;
e1e19a0db57d Minor optimization. If we just checked that the directory existed, don't
Timo Sirainen <tss@iki.fi>
parents: 5468
diff changeset
205 }
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
206 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
207
5539
7d828d1b39ab Added mailbox_list to struct mail_namespace. Added a few functions to get
Timo Sirainen <tss@iki.fi>
parents: 5499
diff changeset
208 if (mailbox_list_init(_storage->ns, "fs", &list_set,
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
209 mail_storage_get_list_flags(_storage->flags),
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
210 &list, &error) < 0) {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
211 i_error("dbox fs: %s", error);
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
212 return -1;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
213 }
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
214 _storage->list = list;
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
215 storage->list_module_ctx.super = list->v;
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
216 list->v.is_valid_existing_name = dbox_storage_is_valid_existing_name;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
217 list->v.is_valid_create_name = dbox_storage_is_valid_create_name;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
218 list->v.iter_is_mailbox = dbox_list_iter_is_mailbox;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
219 list->v.delete_mailbox = dbox_list_delete_mailbox;
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
220
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
221 MODULE_CONTEXT_SET_FULL(list, dbox_mailbox_list_module,
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
222 storage, &storage->list_module_ctx);
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
223
4969
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
224 storage->uidlist_dotlock_set = default_uidlist_dotlock_set;
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
225 storage->file_dotlock_set = default_file_dotlock_set;
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
226 storage->new_file_dotlock_set = default_new_file_dotlock_set;
5461
08b42ced91a6 Removed mail_storage_create_with_data(). mail_storage_create() with
Timo Sirainen <tss@iki.fi>
parents: 5460
diff changeset
227 if ((_storage->flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0) {
4969
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
228 storage->uidlist_dotlock_set.use_excl_lock = TRUE;
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
229 storage->file_dotlock_set.use_excl_lock = TRUE;
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
230 storage->new_file_dotlock_set.use_excl_lock = TRUE;
5c18ac362f65 More dotlock_use_excl uses.
Timo Sirainen <tss@iki.fi>
parents: 4949
diff changeset
231 }
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
232 return 0;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
233 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
234
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3845
diff changeset
235 static bool dbox_autodetect(const char *data, enum mail_storage_flags flags)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
236 {
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3845
diff changeset
237 bool debug = (flags & MAIL_STORAGE_FLAG_DEBUG) != 0;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238 struct stat st;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239 const char *path;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
240
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 data = t_strcut(data, ':');
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
243 path = t_strconcat(data, "/INBOX/"DBOX_MAILDIR_NAME, NULL);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
244 if (stat(path, &st) < 0) {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
245 if (debug)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
246 i_info("dbox autodetect: stat(%s) failed: %m", path);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
247 return FALSE;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
249
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
250 if (!S_ISDIR(st.st_mode)) {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251 if (debug)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
252 i_info("dbox autodetect: %s not a directory", path);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
253 return FALSE;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
254 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
255 return TRUE;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
256 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
258 static int create_dbox(struct mail_storage *storage, const char *path)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260 if (mkdir_parents(path, CREATE_MODE) < 0 && errno != EEXIST) {
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
261 if (!mail_storage_set_error_from_errno(storage)) {
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
262 mail_storage_set_critical(storage,
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
263 "mkdir(%s) failed: %m", path);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
264 }
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
265 return -1;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
266 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
267 return 0;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
268 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
269
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270
5195
840d177c468f cleanup
Timo Sirainen <tss@iki.fi>
parents: 5179
diff changeset
271 static void dbox_lock_touch_timeout(struct dbox_mailbox *mbox)
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
272 {
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
273 (void)dbox_uidlist_lock_touch(mbox->uidlist);
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
274 }
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
275
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
276 static struct mailbox *
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
277 dbox_open(struct dbox_storage *storage, const char *name,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
278 enum mailbox_open_flags flags)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279 {
5459
78eaf595359c Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
280 struct mail_storage *_storage = &storage->storage;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
281 struct dbox_mailbox *mbox;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
282 struct mail_index *index;
5618
5ea33dbddbae Moved index directory creation code to index_storage_alloc().
Timo Sirainen <tss@iki.fi>
parents: 5613
diff changeset
283 const char *path, *value;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
284 pool_t pool;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
285
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
286 path = mailbox_list_get_path(_storage->list, name,
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
287 MAILBOX_LIST_PATH_TYPE_MAILBOX);
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
288 if (create_dbox(_storage, path) < 0)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
289 return NULL;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
290
5618
5ea33dbddbae Moved index directory creation code to index_storage_alloc().
Timo Sirainen <tss@iki.fi>
parents: 5613
diff changeset
291 index = index_storage_alloc(_storage, name, flags, DBOX_INDEX_PREFIX);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
292
5024
a8a274b4c87c Use larger default pool sizes
Timo Sirainen <tss@iki.fi>
parents: 4999
diff changeset
293 pool = pool_alloconly_create("dbox mailbox", 1024+512);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
294 mbox = p_new(pool, struct dbox_mailbox, 1);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
295 mbox->ibox.box = dbox_mailbox;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
296 mbox->ibox.box.pool = pool;
5459
78eaf595359c Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents: 5450
diff changeset
297 mbox->ibox.storage = &storage->storage;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
298 mbox->ibox.mail_vfuncs = &dbox_mail_vfuncs;
5179
2f9ac504ee77 When using KEEP_LOCK, the mbox/uidlist file must be locked before index file
Timo Sirainen <tss@iki.fi>
parents: 5177
diff changeset
299 mbox->ibox.index = index;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
300
3813
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
301 value = getenv("DBOX_ROTATE_SIZE");
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
302 if (value != NULL)
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
303 mbox->rotate_size = (uoff_t)strtoul(value, NULL, 10) * 1024;
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
304 else
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
305 mbox->rotate_size = DBOX_DEFAULT_ROTATE_SIZE;
3845
18a786df5815 Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents: 3813
diff changeset
306 value = getenv("DBOX_ROTATE_MIN_SIZE");
18a786df5815 Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents: 3813
diff changeset
307 if (value != NULL)
18a786df5815 Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents: 3813
diff changeset
308 mbox->rotate_min_size = (uoff_t)strtoul(value, NULL, 10) * 1024;
18a786df5815 Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents: 3813
diff changeset
309 else
18a786df5815 Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents: 3813
diff changeset
310 mbox->rotate_min_size = DBOX_DEFAULT_ROTATE_MIN_SIZE;
3813
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
311 value = getenv("DBOX_ROTATE_DAYS");
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
312 if (value != NULL)
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
313 mbox->rotate_days = (unsigned int)strtoul(value, NULL, 10);
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
314 else
4177
4eaaef28cc38 dbox settings in config file didn't work, and the defaults were also a bit
Timo Sirainen <tss@iki.fi>
parents: 4172
diff changeset
315 mbox->rotate_days = DBOX_DEFAULT_ROTATE_DAYS;
3813
74289963b8a7 Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents: 3720
diff changeset
316
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
317 mbox->storage = storage;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
318 mbox->path = p_strdup(pool, path);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
319 mbox->dbox_file_ext_idx =
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
320 mail_index_ext_register(index, "dbox-seq", 0,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
321 sizeof(uint32_t), sizeof(uint32_t));
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322 mbox->dbox_offset_ext_idx =
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323 mail_index_ext_register(index, "dbox-off", 0,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324 sizeof(uint64_t), sizeof(uint64_t));
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
325
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
326 mbox->uidlist = dbox_uidlist_init(mbox);
5179
2f9ac504ee77 When using KEEP_LOCK, the mbox/uidlist file must be locked before index file
Timo Sirainen <tss@iki.fi>
parents: 5177
diff changeset
327 if ((flags & MAILBOX_OPEN_KEEP_LOCKED) != 0) {
4494
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
328 if (dbox_uidlist_lock(mbox->uidlist) < 0) {
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
329 struct mailbox *box = &mbox->ibox.box;
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
330
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
331 mailbox_close(&box);
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
332 return NULL;
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
333 }
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
334 mbox->keep_lock_to = timeout_add(DBOX_LOCK_TOUCH_MSECS,
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
335 dbox_lock_touch_timeout,
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
336 mbox);
4494
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
337 }
5179
2f9ac504ee77 When using KEEP_LOCK, the mbox/uidlist file must be locked before index file
Timo Sirainen <tss@iki.fi>
parents: 5177
diff changeset
338
2f9ac504ee77 When using KEEP_LOCK, the mbox/uidlist file must be locked before index file
Timo Sirainen <tss@iki.fi>
parents: 5177
diff changeset
339 index_storage_mailbox_init(&mbox->ibox, name, flags, FALSE);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
340 return &mbox->ibox.box;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
341 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
342
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
343 static struct mailbox *
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
344 dbox_mailbox_open(struct mail_storage *_storage, const char *name,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
345 struct istream *input, enum mailbox_open_flags flags)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
346 {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
347 struct dbox_storage *storage = (struct dbox_storage *)_storage;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
348 const char *path;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
349 struct stat st;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
350
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
351 if (input != NULL) {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
352 mail_storage_set_critical(_storage,
4029
9bdd186d7b7d s/Maildir/dbox/
Timo Sirainen <tss@iki.fi>
parents: 4028
diff changeset
353 "dbox doesn't support streamed mailboxes");
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
354 return NULL;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
355 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
356
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
357 if (strcmp(name, "INBOX") == 0)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
358 return dbox_open(storage, "INBOX", flags);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
359
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
360 path = mailbox_list_get_path(_storage->list, name,
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
361 MAILBOX_LIST_PATH_TYPE_MAILBOX);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
362 if (stat(path, &st) == 0) {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
363 return dbox_open(storage, name, flags);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
364 } else if (errno == ENOENT) {
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
365 mail_storage_set_error(_storage, MAIL_ERROR_NOTFOUND,
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
366 T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
367 return NULL;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
368 } else {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
369 mail_storage_set_critical(_storage, "stat(%s) failed: %m",
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
370 path);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
371 return NULL;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
372 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
373 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
374
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
375 static int dbox_mailbox_create(struct mail_storage *_storage,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
376 const char *name,
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3845
diff changeset
377 bool directory __attr_unused__)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
378 {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
379 const char *path;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
380 struct stat st;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
381
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
382 path = mailbox_list_get_path(_storage->list, name,
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
383 MAILBOX_LIST_PATH_TYPE_MAILBOX);
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
384 if (stat(path, &st) == 0) {
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
385 mail_storage_set_error(_storage, MAIL_ERROR_NOTPOSSIBLE,
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
386 "Mailbox already exists");
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
387 return -1;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
388 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
389
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
390 return create_dbox(_storage, path);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
391 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
392
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
393 static int
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
394 dbox_list_delete_mailbox(struct mailbox_list *list, const char *name)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
395 {
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
396 struct dbox_storage *storage = DBOX_LIST_CONTEXT(list);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
397 struct stat st;
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
398 const char *path, *mail_path;
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
399
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
400 /* make sure the indexes are closed before trying to delete the
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
401 directory that contains them */
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
402 index_storage_destroy_unrefed();
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
403
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
404 /* delete the index and control directories */
5450
7a6db5ec047d Better type safety to module_contexts arrays. Already fixed some bugs.
Timo Sirainen <tss@iki.fi>
parents: 5448
diff changeset
405 if (storage->list_module_ctx.super.delete_mailbox(list, name) < 0)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
406 return -1;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
407
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
408 path = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_DIR);
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
409 mail_path = mailbox_list_get_path(list, name,
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
410 MAILBOX_LIST_PATH_TYPE_MAILBOX);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
411
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
412 if (stat(mail_path, &st) < 0 && ENOTFOUND(errno)) {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
413 if (stat(path, &st) < 0) {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
414 /* doesn't exist at all */
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
415 mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
416 T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
417 return -1;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
418 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
419
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
420 /* exists as a \NoSelect mailbox */
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
421 if (rmdir(path) == 0)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
422 return 0;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
423
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
424 if (errno == ENOTEMPTY) {
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
425 mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE,
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
426 t_strdup_printf("Directory %s isn't empty, "
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
427 "can't delete it.", name));
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
428 } else {
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
429 mailbox_list_set_critical(list,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
430 "rmdir() failed for %s: %m", path);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
431 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
432
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
433 return -1;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
434 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
435
4296
e4650b4f4e5a Close index files before trying to unlink the index directory
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4276
diff changeset
436
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
437 if (unlink_directory(mail_path, TRUE) < 0) {
5613
f717fb4b31c0 Error handling rewrite.
Timo Sirainen <tss@iki.fi>
parents: 5562
diff changeset
438 if (!mailbox_list_set_error_from_errno(list)) {
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
439 mailbox_list_set_critical(list,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
440 "unlink_directory() failed for %s: %m",
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
441 mail_path);
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
442 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
443 return -1;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
444 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
445 /* try also removing the root directory. it can fail if the deleted
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
446 mailbox had submailboxes. do it as long as we can. */
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
447 while (rmdir(path) == 0 || errno == ENOENT) {
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
448 const char *p = strrchr(name, '/');
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
449
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
450 if (p == NULL)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
451 break;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
452
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
453 name = t_strdup_until(name, p);
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
454 path = mailbox_list_get_path(list, name,
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
455 MAILBOX_LIST_PATH_TYPE_DIR);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
456 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
457 return 0;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
458 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
459
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
460 static int dbox_storage_close(struct mailbox *box)
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
461 {
4203
4141aae720fe Fixed memory leaks
Timo Sirainen <tss@iki.fi>
parents: 4196
diff changeset
462 struct dbox_mailbox *mbox = (struct dbox_mailbox *)box;
4141aae720fe Fixed memory leaks
Timo Sirainen <tss@iki.fi>
parents: 4196
diff changeset
463
5177
53719357e0e4 If KEEP_LOCK is set and we timeout, don't crash.
Timo Sirainen <tss@iki.fi>
parents: 5176
diff changeset
464 if (mbox->keep_lock_to != NULL) {
4494
e3157540a801 Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents: 4453
diff changeset
465 dbox_uidlist_unlock(mbox->uidlist);
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
466 timeout_remove(&mbox->keep_lock_to);
5177
53719357e0e4 If KEEP_LOCK is set and we timeout, don't crash.
Timo Sirainen <tss@iki.fi>
parents: 5176
diff changeset
467 }
5176
db7b28a3ffbd If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents: 5084
diff changeset
468
4203
4141aae720fe Fixed memory leaks
Timo Sirainen <tss@iki.fi>
parents: 4196
diff changeset
469 dbox_uidlist_deinit(mbox->uidlist);
4141aae720fe Fixed memory leaks
Timo Sirainen <tss@iki.fi>
parents: 4196
diff changeset
470 if (mbox->file != NULL)
4141aae720fe Fixed memory leaks
Timo Sirainen <tss@iki.fi>
parents: 4196
diff changeset
471 dbox_file_close(mbox->file);
5466
8141168f86e1 cleaned up mailbox closing code
Timo Sirainen <tss@iki.fi>
parents: 5465
diff changeset
472 return index_storage_mailbox_close(box);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
473 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
474
5465
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5464
diff changeset
475 static void dbox_notify_changes(struct mailbox *box)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
476 {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
477 struct dbox_mailbox *mbox = (struct dbox_mailbox *)box;
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
478
5465
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5464
diff changeset
479 if (box->notify_callback == NULL)
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
480 index_mailbox_check_remove_all(&mbox->ibox);
5465
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5464
diff changeset
481 else
014236cf3dcc Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents: 5464
diff changeset
482 index_mailbox_check_add(&mbox->ibox, mbox->path);
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
483 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
484
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
485 static int dbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
486 const char *dir, const char *fname,
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
487 enum mailbox_list_file_type type,
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
488 enum mailbox_info_flags *flags)
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
489 {
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
490 const char *mail_path;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
491 struct stat st;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
492 int ret = 1;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
493
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
494 if (strcmp(fname, DBOX_MAILDIR_NAME) == 0) {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
495 *flags = MAILBOX_NOSELECT;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
496 return 0;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
497 }
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
498
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
499 /* try to avoid stat() with these checks */
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
500 if (type != MAILBOX_LIST_FILE_TYPE_DIR &&
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
501 type != MAILBOX_LIST_FILE_TYPE_SYMLINK &&
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
502 type != MAILBOX_LIST_FILE_TYPE_UNKNOWN &&
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
503 (ctx->flags & MAILBOX_LIST_ITER_FAST_FLAGS) != 0) {
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
504 /* it's a file */
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
505 *flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
506 return 0;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
507 }
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
508
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
509 /* need to stat() then */
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
510 t_push();
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
511 mail_path = t_strconcat(dir, "/", fname, "/"DBOX_MAILDIR_NAME, NULL);
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
512
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
513 if (stat(mail_path, &st) == 0) {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
514 if (!S_ISDIR(st.st_mode)) {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
515 /* non-directory */
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
516 *flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
517 ret = 0;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
518 }
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
519 } else {
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
520 /* non-selectable, but may contain subdirs */
5448
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
521 if (errno != ENOTDIR)
beabd433cdae Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents: 5195
diff changeset
522 *flags |= MAILBOX_CHILDREN;
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
523 *flags |= MAILBOX_NOSELECT;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
524 }
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
525 t_pop();
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
526
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
527 return ret;
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
528 }
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
529
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
530 static void dbox_class_init(void)
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
531 {
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
532 dbox_transaction_class_init();
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
533 }
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
534
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
535 static void dbox_class_deinit(void)
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
536 {
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
537 dbox_transaction_class_deinit();
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
538 }
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
539
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
540 struct mail_storage dbox_storage = {
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
541 MEMBER(name) DBOX_STORAGE_NAME,
4808
93bc9770f938 Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents: 4606
diff changeset
542 MEMBER(mailbox_is_file) FALSE,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
543
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
544 {
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
545 dbox_class_init,
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
546 dbox_class_deinit,
5460
105e0cd21036 Added virtual mail_storage.alloc() function and changed create() to work
Timo Sirainen <tss@iki.fi>
parents: 5459
diff changeset
547 dbox_alloc,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
548 dbox_create,
5462
163b48489bc6 Moved all storage destruction code to mail-storage.c and made destroy()
Timo Sirainen <tss@iki.fi>
parents: 5461
diff changeset
549 NULL,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
550 dbox_autodetect,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
551 dbox_mailbox_open,
5468
8e58322ef87e Removed virtual mail_storage.get_last_error(). The implementation is always
Timo Sirainen <tss@iki.fi>
parents: 5466
diff changeset
552 dbox_mailbox_create
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
553 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
554 };
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
555
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
556 struct mailbox dbox_mailbox = {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
557 MEMBER(name) NULL,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
558 MEMBER(storage) NULL,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
559
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
560 {
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
561 index_storage_is_readonly,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
562 index_storage_allow_new_keywords,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
563 dbox_storage_close,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
564 index_storage_get_status,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
565 dbox_storage_sync_init,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
566 index_mailbox_sync_next,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
567 index_mailbox_sync_deinit,
5562
24b751bc0995 Added sync_notify() callback to struct mail_storage. It's now called for
Timo Sirainen <tss@iki.fi>
parents: 5539
diff changeset
568 NULL,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
569 dbox_notify_changes,
4453
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
570 index_transaction_begin,
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
571 index_transaction_commit,
85fcdb478608 Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents: 4395
diff changeset
572 index_transaction_rollback,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
573 index_keywords_create,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
574 index_keywords_free,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
575 index_storage_get_uids,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
576 index_mail_alloc,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
577 index_header_lookup_init,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
578 index_header_lookup_deinit,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
579 index_storage_search_init,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
580 index_storage_search_deinit,
4939
ff2272c228cc Dovecot is now able to execute multiple commands at the same time.
Timo Sirainen <tss@iki.fi>
parents: 4894
diff changeset
581 index_storage_search_next_nonblock,
4196
6ac0d63b297f Optimized searching a bit for cases where we can restrict search range by
Timo Sirainen <tss@iki.fi>
parents: 4177
diff changeset
582 index_storage_search_next_update_seq,
3720
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
583 dbox_save_init,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
584 dbox_save_continue,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
585 dbox_save_finish,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
586 dbox_save_cancel,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
587 mail_storage_copy,
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
588 index_storage_is_inconsistent
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
589 }
fd0986477809 Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
590 };