Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-storage/index/dbox/dbox-storage.c @ 5539:7d828d1b39ab HEAD
Added mailbox_list to struct mail_namespace. Added a few functions to get
private data out of mailbox_list.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 11 Apr 2007 13:55:34 +0300 |
parents | e1e19a0db57d |
children | 24b751bc0995 |
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 | 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 | 28 const struct dotlock_settings default_uidlist_dotlock_set = { |
29 MEMBER(temp_prefix) NULL, | |
30 MEMBER(lock_suffix) NULL, | |
31 | |
32 MEMBER(timeout) 120, | |
33 MEMBER(stale_timeout) 60, | |
34 | |
35 MEMBER(callback) NULL, | |
36 MEMBER(context) NULL, | |
37 | |
38 MEMBER(use_excl_lock) FALSE | |
39 }; | |
40 | |
41 const struct dotlock_settings default_file_dotlock_set = { | |
42 MEMBER(temp_prefix) NULL, | |
43 MEMBER(lock_suffix) NULL, | |
44 | |
45 MEMBER(timeout) 120, | |
46 MEMBER(stale_timeout) 60, | |
47 | |
48 MEMBER(callback) NULL, | |
49 MEMBER(context) NULL, | |
50 | |
51 MEMBER(use_excl_lock) FALSE | |
52 }; | |
53 | |
54 static const struct dotlock_settings default_new_file_dotlock_set = { | |
55 MEMBER(temp_prefix) NULL, | |
56 MEMBER(lock_suffix) NULL, | |
57 | |
58 MEMBER(timeout) 60, | |
59 MEMBER(stale_timeout) 30, | |
60 | |
61 MEMBER(callback) NULL, | |
62 MEMBER(context) NULL, | |
63 | |
64 MEMBER(use_excl_lock) FALSE | |
65 }; | |
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 | 224 storage->uidlist_dotlock_set = default_uidlist_dotlock_set; |
225 storage->file_dotlock_set = default_file_dotlock_set; | |
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 | 228 storage->uidlist_dotlock_set.use_excl_lock = TRUE; |
229 storage->file_dotlock_set.use_excl_lock = TRUE; | |
230 storage->new_file_dotlock_set.use_excl_lock = TRUE; | |
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 { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
260 const char *error; |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
261 |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
262 if (mkdir_parents(path, CREATE_MODE) < 0 && errno != EEXIST) { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
263 if (mail_storage_errno2str(&error)) { |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
264 mail_storage_set_error(storage, "%s", error); |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
265 return -1; |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
266 } |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
267 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
268 mail_storage_set_critical(storage, "mkdir(%s) failed: %m", |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
269 path); |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
270 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
271 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
272 return 0; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
273 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
274 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
275 static int create_index_dir(struct mail_storage *storage, const char *name) |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
276 { |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
277 const char *root_dir, *index_dir; |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
278 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
279 root_dir = 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
|
280 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
|
281 index_dir = 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
|
282 MAILBOX_LIST_PATH_TYPE_INDEX); |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
283 if (strcmp(index_dir, root_dir) == 0) |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
284 return 0; |
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 if (mkdir_parents(index_dir, CREATE_MODE) < 0 && errno != EEXIST) { |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
287 mail_storage_set_critical(storage, "mkdir(%s) failed: %m", |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
288 index_dir); |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
289 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
290 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
291 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
292 return 0; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
293 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
294 |
5195 | 295 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
|
296 { |
db7b28a3ffbd
If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents:
5084
diff
changeset
|
297 (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
|
298 } |
db7b28a3ffbd
If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents:
5084
diff
changeset
|
299 |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
300 static struct mailbox * |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
301 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
|
302 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
|
303 { |
5459
78eaf595359c
Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents:
5450
diff
changeset
|
304 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
|
305 struct dbox_mailbox *mbox; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
306 struct mail_index *index; |
3813
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
307 const char *path, *index_dir, *value; |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
308 pool_t pool; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
309 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
310 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
|
311 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
|
312 index_dir = 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
|
313 MAILBOX_LIST_PATH_TYPE_INDEX); |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
314 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
315 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
|
316 return NULL; |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
317 if (create_index_dir(_storage, name) < 0) |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
318 return NULL; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
319 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
320 index = index_storage_alloc(index_dir, path, DBOX_INDEX_PREFIX); |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
321 |
5024 | 322 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
|
323 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
|
324 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
|
325 mbox->ibox.box.pool = pool; |
5459
78eaf595359c
Removed struct index_storage abstraction. It's pointless.
Timo Sirainen <tss@iki.fi>
parents:
5450
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 |
3813
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
330 value = getenv("DBOX_ROTATE_SIZE"); |
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
331 if (value != NULL) |
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
332 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
|
333 else |
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
334 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
|
335 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
|
336 if (value != NULL) |
18a786df5815
Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents:
3813
diff
changeset
|
337 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
|
338 else |
18a786df5815
Added dbox_rotate_min_size and fixed rotation checks.
Timo Sirainen <tss@iki.fi>
parents:
3813
diff
changeset
|
339 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
|
340 value = getenv("DBOX_ROTATE_DAYS"); |
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
341 if (value != NULL) |
74289963b8a7
Added dbox_rotate_size and dbox_rotate_days settings.
Timo Sirainen <tss@iki.fi>
parents:
3720
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
346 mbox->storage = storage; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
355 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
|
356 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
|
357 if (dbox_uidlist_lock(mbox->uidlist) < 0) { |
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
358 struct mailbox *box = &mbox->ibox.box; |
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
359 |
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
360 mailbox_close(&box); |
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
361 return NULL; |
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
362 } |
5176
db7b28a3ffbd
If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents:
5084
diff
changeset
|
363 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
|
364 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
|
365 mbox); |
4494
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
366 } |
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
|
367 |
2f9ac504ee77
When using KEEP_LOCK, the mbox/uidlist file must be locked before index file
Timo Sirainen <tss@iki.fi>
parents:
5177
diff
changeset
|
368 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
|
369 return &mbox->ibox.box; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
370 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
371 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
372 static struct mailbox * |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
373 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
|
374 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
|
375 { |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
376 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
|
377 const char *path; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
378 struct stat st; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
379 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
380 if (input != NULL) { |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
381 mail_storage_set_critical(_storage, |
4029 | 382 "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
|
383 return NULL; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
384 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
385 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
386 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
|
387 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
|
388 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
389 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
|
390 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
|
391 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
|
392 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
|
393 } else if (errno == ENOENT) { |
4041
9d7420b0e1ef
Make life easier for plugins:
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4029
diff
changeset
|
394 mail_storage_set_error(_storage, |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
395 MAILBOX_LIST_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
|
396 return NULL; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
397 } else { |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
398 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
|
399 path); |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
400 return NULL; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
401 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
402 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
403 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 { |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
408 const char *path; |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
409 struct stat st; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
410 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
411 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
|
412 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
|
413 if (stat(path, &st) == 0) { |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
414 mail_storage_set_error(_storage, "Mailbox already exists"); |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
415 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
416 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
417 |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
418 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
|
419 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
420 |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
421 static int |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
422 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
|
423 { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
424 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
|
425 struct stat st; |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
426 const char *path, *mail_path, *error; |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
427 |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
428 /* 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
|
429 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
|
430 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
|
431 |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
432 /* 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
|
433 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
|
434 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
435 |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
436 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
|
437 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
|
438 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
|
439 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
440 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
|
441 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
|
442 /* doesn't exist at all */ |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
443 mailbox_list_set_error(list, t_strdup_printf( |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
444 MAILBOX_LIST_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
|
445 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
446 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
447 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
448 /* 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
|
449 if (rmdir(path) == 0) |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
450 return 0; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
451 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
452 if (errno == ENOTEMPTY) { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
453 mailbox_list_set_error(list, t_strdup_printf( |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
454 "Directory %s isn't empty, can't delete it.", |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
455 name)); |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
456 } else { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
457 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
|
458 "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
|
459 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
460 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
461 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
462 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
463 |
4296
e4650b4f4e5a
Close index files before trying to unlink the index directory
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4276
diff
changeset
|
464 |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
465 if (unlink_directory(mail_path, TRUE) < 0) { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
466 if (mail_storage_errno2str(&error)) |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
467 mailbox_list_set_error(list, error); |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
468 else { |
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
469 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
|
470 "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
|
471 mail_path); |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
472 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
473 return -1; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
474 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
475 /* 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
|
476 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
|
477 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
|
478 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
|
479 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
480 if (p == NULL) |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
481 break; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
482 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
487 return 0; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
488 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
489 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
490 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
|
491 { |
4203 | 492 struct dbox_mailbox *mbox = (struct dbox_mailbox *)box; |
493 | |
5177
53719357e0e4
If KEEP_LOCK is set and we timeout, don't crash.
Timo Sirainen <tss@iki.fi>
parents:
5176
diff
changeset
|
494 if (mbox->keep_lock_to != NULL) { |
4494
e3157540a801
Make pop3_lock_session work with dbox.
Timo Sirainen <tss@iki.fi>
parents:
4453
diff
changeset
|
495 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
|
496 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
|
497 } |
5176
db7b28a3ffbd
If pop3_lock_session=yes, update maildir/dbox uidlist lock file every 10
Timo Sirainen <tss@iki.fi>
parents:
5084
diff
changeset
|
498 |
4203 | 499 dbox_uidlist_deinit(mbox->uidlist); |
500 if (mbox->file != NULL) | |
501 dbox_file_close(mbox->file); | |
5466
8141168f86e1
cleaned up mailbox closing code
Timo Sirainen <tss@iki.fi>
parents:
5465
diff
changeset
|
502 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
|
503 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
504 |
5465
014236cf3dcc
Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents:
5464
diff
changeset
|
505 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
|
506 { |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
507 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
|
508 |
5465
014236cf3dcc
Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents:
5464
diff
changeset
|
509 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
|
510 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
|
511 else |
014236cf3dcc
Moved notify settings to struct mailbox. Removed the parameters from
Timo Sirainen <tss@iki.fi>
parents:
5464
diff
changeset
|
512 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
|
513 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
514 |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
515 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
|
516 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
|
517 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
|
518 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
|
519 { |
5448
beabd433cdae
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
Timo Sirainen <tss@iki.fi>
parents:
5195
diff
changeset
|
520 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
|
521 struct stat st; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
522 int ret = 1; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
523 |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
524 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
|
525 *flags = MAILBOX_NOSELECT; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
526 return 0; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
527 } |
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 /* 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
|
530 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
|
531 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
|
532 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
|
533 (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
|
534 /* it's a file */ |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
535 *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
|
536 return 0; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
537 } |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
538 |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
539 /* need to stat() then */ |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
540 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
|
541 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
|
542 |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
543 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
|
544 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
|
545 /* non-directory */ |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
546 *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
|
547 ret = 0; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
548 } |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
549 } else { |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
550 /* 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
|
551 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
|
552 *flags |= MAILBOX_CHILDREN; |
4808
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
553 *flags |= MAILBOX_NOSELECT; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
554 } |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
555 t_pop(); |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
556 |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
557 return ret; |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
558 } |
93bc9770f938
Initial code for separation of mailbox accessing and directory layout
Timo Sirainen <tss@iki.fi>
parents:
4606
diff
changeset
|
559 |
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
|
560 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
|
561 { |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4395
diff
changeset
|
562 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
|
563 } |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4395
diff
changeset
|
564 |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4395
diff
changeset
|
565 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
|
566 { |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4395
diff
changeset
|
567 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
|
568 } |
85fcdb478608
Beginnings of joining mail-storage API more closely to mail-index, so that
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4395
diff
changeset
|
569 |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
570 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
|
571 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
|
572 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
|
573 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
574 { |
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
|
575 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
|
576 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
|
577 dbox_alloc, |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
578 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
|
579 NULL, |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
580 dbox_autodetect, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
581 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
|
582 dbox_mailbox_create |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
583 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
584 }; |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
585 |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
586 struct mailbox dbox_mailbox = { |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
587 MEMBER(name) NULL, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
588 MEMBER(storage) NULL, |
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 { |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
591 index_storage_is_readonly, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
592 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
|
593 dbox_storage_close, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
594 index_storage_get_status, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
595 dbox_storage_sync_init, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
596 index_mailbox_sync_next, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
597 index_mailbox_sync_deinit, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
598 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
|
599 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
|
600 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
|
601 index_transaction_rollback, |
3720
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
602 index_keywords_create, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
603 index_keywords_free, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
604 index_storage_get_uids, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
605 index_mail_alloc, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
606 index_header_lookup_init, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
607 index_header_lookup_deinit, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
608 index_storage_search_init, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
609 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
|
610 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
|
611 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
|
612 dbox_save_init, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
613 dbox_save_continue, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
614 dbox_save_finish, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
615 dbox_save_cancel, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
616 mail_storage_copy, |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
617 index_storage_is_inconsistent |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
618 } |
fd0986477809
Initial implementation of Dovecot's own high performance file format, named
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
619 }; |