Mercurial > dovecot > core-2.2
annotate src/lib-storage/index/index-storage.c @ 13:bb294faf7379 HEAD
"Critical errors" aren't displayed to users anymore, ie. anything that is
not a predefined human readable error message is written into log file and
user gets only "Internal error [timestamp]".
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 22 Aug 2002 17:50:16 +0300 |
parents | 82b7de533f98 |
children | 306c20092a96 |
rev | line source |
---|---|
0 | 1 /* Copyright (C) 2002 Timo Sirainen */ |
2 | |
3 #include "lib.h" | |
4 #include "mail-index.h" | |
5 #include "index-storage.h" | |
6 | |
7 IndexMailbox *index_storage_init(MailStorage *storage, Mailbox *box, | |
8 MailIndex *index, const char *name, | |
9 int readonly) | |
10 { | |
11 IndexMailbox *ibox; | |
12 FlagsFile *flagsfile; | |
13
bb294faf7379
"Critical errors" aren't displayed to users anymore, ie. anything that is
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
13 const char *path; |
0 | 14 |
15 i_assert(name != NULL); | |
16 | |
17 /* open the index first */ | |
18 if (!index->open_or_create(index, !readonly)) { | |
13
bb294faf7379
"Critical errors" aren't displayed to users anymore, ie. anything that is
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
19 mail_storage_set_internal_error(storage); |
0 | 20 index->free(index); |
21 return NULL; | |
22 } | |
23 | |
24 /* then flags file */ | |
25 path = t_strconcat(index->dir, "/", FLAGS_FILE_NAME, NULL); | |
26 flagsfile = flags_file_open_or_create(storage, path); | |
27 if (flagsfile == NULL) { | |
28 index->free(index); | |
29 return NULL; | |
30 } | |
31 | |
32 ibox = i_new(IndexMailbox, 1); | |
33 ibox->box = *box; | |
34 | |
35 ibox->box.storage = storage; | |
36 ibox->box.name = i_strdup(name); | |
37 ibox->box.readonly = readonly; | |
38 | |
39 ibox->index = index; | |
40 ibox->flagsfile = flagsfile; | |
41 ibox->cache = imap_msgcache_alloc(); | |
42 | |
43 return ibox; | |
44 } | |
45 | |
46 void index_storage_close(Mailbox *box) | |
47 { | |
48 IndexMailbox *ibox = (IndexMailbox *) box; | |
49 | |
50 flags_file_destroy(ibox->flagsfile); | |
51 imap_msgcache_free(ibox->cache); | |
52 ibox->index->free(ibox->index); | |
53 i_free(box->name); | |
54 i_free(box); | |
55 } | |
56 | |
57 int mail_storage_set_index_error(IndexMailbox *ibox) | |
58 { | |
59 ibox->box.inconsistent = | |
60 ibox->index->is_inconsistency_error(ibox->index); | |
13
bb294faf7379
"Critical errors" aren't displayed to users anymore, ie. anything that is
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
61 mail_storage_set_internal_error(ibox->box.storage); |
0 | 62 return FALSE; |
63 } | |
64 | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
65 static MailFlags get_used_flags(void *context) |
0 | 66 { |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
67 IndexMailbox *ibox = context; |
0 | 68 MailIndexRecord *rec; |
69 MailFlags used_flags; | |
70 | |
71 used_flags = 0; | |
72 | |
73 rec = ibox->index->lookup(ibox->index, 1); | |
74 while (rec != NULL) { | |
75 used_flags |= rec->msg_flags; | |
76 rec = ibox->index->next(ibox->index, rec); | |
77 } | |
78 | |
79 return used_flags; | |
80 } | |
81 | |
82 int index_mailbox_fix_custom_flags(IndexMailbox *ibox, MailFlags *flags, | |
83 const char *custom_flags[]) | |
84 { | |
85 return flags_file_fix_custom_flags(ibox->flagsfile, flags, | |
86 custom_flags, get_used_flags, ibox); | |
87 } |