annotate src/lib-storage/index/index-sync.c @ 8590:b9faf4db2a9f HEAD

Updated copyright notices to include year 2009.
author Timo Sirainen <tss@iki.fi>
date Tue, 06 Jan 2009 09:25:38 -0500
parents 66dd5f452d32
children 387f84b2768e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8590
b9faf4db2a9f Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents: 8132
diff changeset
1 /* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
4688
764bd841e0ae Try to avoid sending duplicate/useless flag updates.
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
4 #include "seq-range-array.h"
7291
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
5 #include "ioloop.h"
3822
5ba04396479d Make it compile..
Timo Sirainen <tss@iki.fi>
parents: 3821
diff changeset
6 #include "array.h"
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7624
diff changeset
7 #include "index-sync-private.h"
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
8
7291
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
9 bool index_mailbox_want_full_sync(struct index_mailbox *ibox,
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
10 enum mailbox_sync_flags flags)
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
11 {
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
12 if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 &&
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
13 ioloop_time < ibox->sync_last_check + MAILBOX_FULL_SYNC_INTERVAL)
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
14 return FALSE;
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
15
7292
d0520bb9177f mailbox_notify_changes(): Don't trigger the timeout once a second to see if
Timo Sirainen <tss@iki.fi>
parents: 7291
diff changeset
16 if (ibox->notify_to != NULL)
d0520bb9177f mailbox_notify_changes(): Don't trigger the timeout once a second to see if
Timo Sirainen <tss@iki.fi>
parents: 7291
diff changeset
17 timeout_reset(ibox->notify_to);
7291
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
18 ibox->sync_last_check = ioloop_time;
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
19 return TRUE;
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
20 }
db65d921b0e1 Check and update sync_last_check in one common function.
Timo Sirainen <tss@iki.fi>
parents: 7174
diff changeset
21
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
22 void index_mailbox_set_recent_uid(struct index_mailbox *ibox, uint32_t uid)
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
23 {
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
24 if (uid <= ibox->recent_flags_prev_uid) {
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
25 i_assert(seq_range_exists(&ibox->recent_flags, uid));
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
26 return;
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
27 }
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
28 ibox->recent_flags_prev_uid = uid;
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
29
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
30 seq_range_array_add(&ibox->recent_flags, 64, uid);
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
31 ibox->recent_flags_count++;
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
32 }
4073
cd701884900c Memory leak fixes
Timo Sirainen <tss@iki.fi>
parents: 3979
diff changeset
33
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
34 void index_mailbox_set_recent_seq(struct index_mailbox *ibox,
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
35 struct mail_index_view *view,
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
36 uint32_t seq1, uint32_t seq2)
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
37 {
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
38 uint32_t uid;
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
39
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
40 for (; seq1 <= seq2; seq1++) {
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
41 mail_index_lookup_uid(view, seq1, &uid);
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
42 index_mailbox_set_recent_uid(ibox, uid);
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
43 }
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
44 }
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
45
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
46 bool index_mailbox_is_recent(struct index_mailbox *ibox, uint32_t uid)
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
47 {
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
48 return array_is_created(&ibox->recent_flags) &&
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
49 seq_range_exists(&ibox->recent_flags, uid);
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
50 }
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
51
7463
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
52 void index_mailbox_reset_uidvalidity(struct index_mailbox *ibox)
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
53 {
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
54 /* can't trust the currently cached recent flags anymore */
7464
4dc5542f58aa Fixes to handling recent flags with UIDVALIDITY changing.
Timo Sirainen <tss@iki.fi>
parents: 7463
diff changeset
55 if (array_is_created(&ibox->recent_flags))
4dc5542f58aa Fixes to handling recent flags with UIDVALIDITY changing.
Timo Sirainen <tss@iki.fi>
parents: 7463
diff changeset
56 array_clear(&ibox->recent_flags);
7463
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
57 ibox->recent_flags_count = 0;
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
58 ibox->recent_flags_prev_uid = 0;
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
59 }
d1bd08d468d0 Reset cached \Recent flags if UIDVALIDITY changes, because we were using
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
60
6038
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
61 unsigned int index_mailbox_get_recent_count(struct index_mailbox *ibox)
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
62 {
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
63 const struct mail_index_header *hdr;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
64 const struct seq_range *range;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
65 unsigned int i, count, recent_count;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
66
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
67 if (!array_is_created(&ibox->recent_flags))
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
68 return 0;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
69
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
70 hdr = mail_index_get_header(ibox->view);
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
71 recent_count = ibox->recent_flags_count;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
72 range = array_get(&ibox->recent_flags, &count);
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
73 for (i = count; i > 0; ) {
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
74 i--;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
75 if (range[i].seq2 < hdr->next_uid)
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
76 break;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
77
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
78 if (range[i].seq1 >= hdr->next_uid) {
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
79 /* completely invisible to this view */
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
80 recent_count -= range[i].seq2 - range[i].seq1 + 1;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
81 } else {
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
82 /* partially invisible */
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
83 recent_count -= range[i].seq2 - hdr->next_uid + 1;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
84 break;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
85 }
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
86 }
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
87 return recent_count;
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
88 }
cadb5b7cd919 Fixes to recent handling. Now it should work properly.
Timo Sirainen <tss@iki.fi>
parents: 6037
diff changeset
89
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
90 static void index_mailbox_expunge_recent(struct index_mailbox *ibox,
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
91 uint32_t seq1, uint32_t seq2)
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
92 {
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
93 uint32_t uid;
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
94
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
95 if (!array_is_created(&ibox->recent_flags))
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
96 return;
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
97
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
98 for (; seq1 <= seq2; seq1++) {
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
99 mail_index_lookup_uid(ibox->view, seq1, &uid);
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
100 if (seq_range_array_remove(&ibox->recent_flags, uid))
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
101 ibox->recent_flags_count--;
2317
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
102 }
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
103 }
0cf316c77b1b Recent flags should be fully working now with maildir.
Timo Sirainen <tss@iki.fi>
parents: 2062
diff changeset
104
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
105 static void index_view_sync_recs_get(struct index_mailbox_sync_context *ctx)
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
106 {
7561
1a58b18652a6 Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents: 7464
diff changeset
107 struct mail_index_view_sync_rec sync_rec;
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
108 uint32_t seq1, seq2;
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
109
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
110 i_array_init(&ctx->flag_updates, 128);
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
111 i_array_init(&ctx->hidden_updates, 32);
7561
1a58b18652a6 Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents: 7464
diff changeset
112 while (mail_index_view_sync_next(ctx->sync_ctx, &sync_rec)) {
1a58b18652a6 Avoid using shadow variables. Unfortunately -Wshadow also complains about
Timo Sirainen <tss@iki.fi>
parents: 7464
diff changeset
113 switch (sync_rec.type) {
7875
8ded6c06bcfc Changed mail index view syncing API to return only flag changes.
Timo Sirainen <tss@iki.fi>
parents: 7872
diff changeset
114 case MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS:
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
115 if (!mail_index_lookup_seq_range(ctx->ibox->view,
7875
8ded6c06bcfc Changed mail index view syncing API to return only flag changes.
Timo Sirainen <tss@iki.fi>
parents: 7872
diff changeset
116 sync_rec.uid1,
8ded6c06bcfc Changed mail index view syncing API to return only flag changes.
Timo Sirainen <tss@iki.fi>
parents: 7872
diff changeset
117 sync_rec.uid2,
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
118 &seq1, &seq2))
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
119 break;
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
120
7798
8e206e25a142 Merged latest v1.1 changes.
Timo Sirainen <tss@iki.fi>
parents: 7647 7616
diff changeset
121 if (!sync_rec.hidden) {
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
122 seq_range_array_add_range(&ctx->flag_updates,
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
123 seq1, seq2);
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
124 } else if (array_is_created(&ctx->hidden_updates)) {
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
125 seq_range_array_add_range(&ctx->hidden_updates,
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
126 seq1, seq2);
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
127 }
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
128 break;
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
129 }
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
130 }
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
131
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
132 /* remove expunged messages from flag updates */
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
133 if (ctx->expunges != NULL) {
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
134 seq_range_array_remove_seq_range(&ctx->flag_updates,
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
135 ctx->expunges);
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
136 seq_range_array_remove_seq_range(&ctx->hidden_updates,
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
137 ctx->expunges);
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
138 }
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
139 /* remove flag updates from hidden updates */
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
140 seq_range_array_remove_seq_range(&ctx->hidden_updates,
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
141 &ctx->flag_updates);
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
142 }
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
143
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
144 struct mailbox_sync_context *
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
145 index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags,
3863
55df57c028d4 Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents: 3834
diff changeset
146 bool failed)
453
0f6fd6802265 Modify log now stores the changes in ranges, so store 1:100 doesn't
Timo Sirainen <tss@iki.fi>
parents: 452
diff changeset
147 {
1915
79790750c349 importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents: 1730
diff changeset
148 struct index_mailbox *ibox = (struct index_mailbox *)box;
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
149 struct index_mailbox_sync_context *ctx;
5764
4dcb14706561 mail_index_view_sync_begin() can now sync only all or all but expunges.
Timo Sirainen <tss@iki.fi>
parents: 5763
diff changeset
150 enum mail_index_view_sync_flags sync_flags = 0;
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
151
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
152 ctx = i_new(struct index_mailbox_sync_context, 1);
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
153 ctx->ctx.box = box;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
154 ctx->ibox = ibox;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
155
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
156 if (failed) {
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
157 ctx->failed = TRUE;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
158 return &ctx->ctx;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
159 }
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
160
6676
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
161 if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) != 0)
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
162 sync_flags |= MAIL_INDEX_VIEW_SYNC_FLAG_NOEXPUNGES;
939
24b64302f59c index_storage_sync_and_lock() didn't set lock notify function.
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
163
6676
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
164 if ((flags & MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) != 0) {
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
165 sync_flags |= MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT;
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
166 ctx->messages_count = 0;
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
167 } else {
6674
2637fb191e5e Added MAILBOX_SYNC_FLAG_FIX_INCONSISTENT flag. mailbox_sync() uses it
Timo Sirainen <tss@iki.fi>
parents: 6673
diff changeset
168 ctx->messages_count =
2637fb191e5e Added MAILBOX_SYNC_FLAG_FIX_INCONSISTENT flag. mailbox_sync() uses it
Timo Sirainen <tss@iki.fi>
parents: 6673
diff changeset
169 mail_index_view_get_messages_count(ibox->view);
6676
6a54a5339a64 Use MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT instead of handling
Timo Sirainen <tss@iki.fi>
parents: 6674
diff changeset
170 }
6674
2637fb191e5e Added MAILBOX_SYNC_FLAG_FIX_INCONSISTENT flag. mailbox_sync() uses it
Timo Sirainen <tss@iki.fi>
parents: 6673
diff changeset
171
7872
3882c6cbfa99 mail_index_view_sync_begin() now delays its failures to _commit().
Timo Sirainen <tss@iki.fi>
parents: 7815
diff changeset
172 ctx->sync_ctx = mail_index_view_sync_begin(ibox->view, sync_flags);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
173 if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) {
4688
764bd841e0ae Try to avoid sending duplicate/useless flag updates.
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
174 mail_index_view_sync_get_expunges(ctx->sync_ctx,
764bd841e0ae Try to avoid sending duplicate/useless flag updates.
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
175 &ctx->expunges);
764bd841e0ae Try to avoid sending duplicate/useless flag updates.
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
176 ctx->expunge_pos = array_count(ctx->expunges);
450
925d6eb5f8be MailStorage interface change. We now let storage call several sync-functions
Timo Sirainen <tss@iki.fi>
parents: 355
diff changeset
177 }
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
178 index_view_sync_recs_get(ctx);
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7624
diff changeset
179 index_sync_search_results_expunge(ctx);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
180 return &ctx->ctx;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
181 }
450
925d6eb5f8be MailStorage interface change. We now let storage call several sync-functions
Timo Sirainen <tss@iki.fi>
parents: 355
diff changeset
182
7616
dcdf6f9e1fc0 Minor code cleanup
Timo Sirainen <tss@iki.fi>
parents: 7561
diff changeset
183 static bool
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
184 index_mailbox_sync_next_expunge(struct index_mailbox_sync_context *ctx,
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
185 struct mailbox_sync_rec *sync_rec_r)
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
186 {
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
187 const struct seq_range *range;
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
188
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
189 if (ctx->expunge_pos == 0)
7616
dcdf6f9e1fc0 Minor code cleanup
Timo Sirainen <tss@iki.fi>
parents: 7561
diff changeset
190 return FALSE;
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
191
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
192 /* expunges is a sorted array of sequences. it's easiest for
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
193 us to print them from end to beginning. */
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
194 ctx->expunge_pos--;
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
195 range = array_idx(ctx->expunges, ctx->expunge_pos);
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
196 i_assert(range->seq2 <= ctx->messages_count);
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
197
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
198 index_mailbox_expunge_recent(ctx->ibox, range->seq1, range->seq2);
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
199 ctx->messages_count -= range->seq2 - range->seq1 + 1;
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
200
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
201 sync_rec_r->seq1 = range->seq1;
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
202 sync_rec_r->seq2 = range->seq2;
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
203 sync_rec_r->type = MAILBOX_SYNC_TYPE_EXPUNGE;
7616
dcdf6f9e1fc0 Minor code cleanup
Timo Sirainen <tss@iki.fi>
parents: 7561
diff changeset
204 return TRUE;
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
205 }
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
206
6279
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
207 bool index_mailbox_sync_next(struct mailbox_sync_context *_ctx,
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
208 struct mailbox_sync_rec *sync_rec_r)
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
209 {
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
210 struct index_mailbox_sync_context *ctx =
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
211 (struct index_mailbox_sync_context *)_ctx;
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
212 const struct seq_range *range;
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
213 unsigned int count;
1984
9c159272f721 syncing fixes
Timo Sirainen <tss@iki.fi>
parents: 1947
diff changeset
214
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
215 if (ctx->failed)
6279
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
216 return FALSE;
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
217
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
218 range = array_get(&ctx->flag_updates, &count);
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
219 if (ctx->flag_update_idx < count) {
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
220 sync_rec_r->type = MAILBOX_SYNC_TYPE_FLAGS;
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
221 sync_rec_r->seq1 = range[ctx->flag_update_idx].seq1;
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
222 sync_rec_r->seq2 = range[ctx->flag_update_idx].seq2;
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
223 ctx->flag_update_idx++;
7616
dcdf6f9e1fc0 Minor code cleanup
Timo Sirainen <tss@iki.fi>
parents: 7561
diff changeset
224 return TRUE;
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
225 }
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
226 if ((_ctx->box->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0) {
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
227 /* hidden flag changes' MODSEQs still need to be returned */
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
228 range = array_get(&ctx->hidden_updates, &count);
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
229 if (ctx->hidden_update_idx < count) {
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
230 sync_rec_r->type = MAILBOX_SYNC_TYPE_MODSEQ;
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
231 sync_rec_r->seq1 = range[ctx->hidden_update_idx].seq1;
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
232 sync_rec_r->seq2 = range[ctx->hidden_update_idx].seq2;
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
233 ctx->hidden_update_idx++;
7798
8e206e25a142 Merged latest v1.1 changes.
Timo Sirainen <tss@iki.fi>
parents: 7647 7616
diff changeset
234 return TRUE;
7624
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
235 }
271131a1e060 View sync returns now also hidden records, but they're marked as such.
Timo Sirainen <tss@iki.fi>
parents: 7292
diff changeset
236 }
1984
9c159272f721 syncing fixes
Timo Sirainen <tss@iki.fi>
parents: 1947
diff changeset
237
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
238 return index_mailbox_sync_next_expunge(ctx, sync_rec_r);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
239 }
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
240
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
241 static void
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
242 index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
243 {
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
244 struct index_mailbox *ibox = ctx->ibox;
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
245 const struct mail_index_header *hdr;
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
246 uint32_t seq, start_uid, uid;
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
247
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
248 if (!array_is_created(&ibox->recent_flags))
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
249 return;
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
250
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
251 /* expunges array contained expunges for the messages that were already
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
252 visible in this view, but append+expunge would be invisible.
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
253 recent_flags may however contain the append UID, so we'll have to
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
254 remove it separately */
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
255 hdr = mail_index_get_header(ibox->view);
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
256 if (ctx->messages_count == 0)
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
257 uid = 0;
6673
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
258 else if (ctx->messages_count <= hdr->messages_count)
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
259 mail_index_lookup_uid(ibox->view, ctx->messages_count, &uid);
6673
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
260 else {
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
261 i_assert(mail_index_view_is_inconsistent(ibox->view));
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
262 return;
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
263 }
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
264
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
265 for (seq = ctx->messages_count + 1; seq <= hdr->messages_count; seq++) {
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
266 start_uid = uid;
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
267 mail_index_lookup_uid(ibox->view, seq, &uid);
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
268 if (start_uid + 1 > uid - 1)
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
269 continue;
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
270
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
271 ibox->recent_flags_count -=
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
272 seq_range_array_remove_range(&ibox->recent_flags,
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
273 start_uid + 1, uid - 1);
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
274 }
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
275
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
276 if (uid + 1 < hdr->next_uid) {
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
277 ibox->recent_flags_count -=
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
278 seq_range_array_remove_range(&ibox->recent_flags,
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
279 uid + 1,
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
280 hdr->next_uid - 1);
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
281 }
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
282 #ifdef DEBUG
8132
66dd5f452d32 DEBUG: Don't verify recent flags if view is already marked inconsistent.
Timo Sirainen <tss@iki.fi>
parents: 7888
diff changeset
283 if (!mail_index_view_is_inconsistent(ibox->view)) {
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
284 const struct seq_range *range;
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
285 unsigned int i, count;
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
286
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
287 range = array_get(&ibox->recent_flags, &count);
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
288 for (i = 0; i < count; i++) {
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
289 for (uid = range[i].seq1; uid <= range[i].seq2; uid++) {
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
290 if (uid >= hdr->next_uid)
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
291 break;
6677
90bcf480312d Renamed mail_index_lookup_uid_range() to mail_index_lookup_seq_range(), made
Timo Sirainen <tss@iki.fi>
parents: 6676
diff changeset
292 mail_index_lookup_seq(ibox->view, uid, &seq);
6103
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
293 i_assert(seq != 0);
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
294 }
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
295 }
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
296 }
15f845e16a91 Fixes to handling recent flags. Also if DEBUG is enabled, scan through the
Timo Sirainen <tss@iki.fi>
parents: 6041
diff changeset
297 #endif
6041
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
298 }
f2ab0b7e5ae6 If a message was expunged that wasn't yet even visible to our view, it might
Timo Sirainen <tss@iki.fi>
parents: 6038
diff changeset
299
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
300 int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx,
4848
967de900c73a Mailbox list indexing and related changes. Currently works only with
Timo Sirainen <tss@iki.fi>
parents: 4688
diff changeset
301 enum mailbox_status_items status_items,
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
302 struct mailbox_status *status_r)
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
303 {
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
304 struct index_mailbox_sync_context *ctx =
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
305 (struct index_mailbox_sync_context *)_ctx;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
306 struct index_mailbox *ibox = ctx->ibox;
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
307 struct mailbox_sync_rec sync_rec;
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
308 const struct mail_index_header *hdr;
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
309 uint32_t seq1, seq2;
7815
2d62129a709b QRESYNC: If MODSEQs were returned in FETCH replies but there are pending
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
310 bool delayed_expunges = FALSE;
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
311 int ret = ctx->failed ? -1 : 0;
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
312
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
313 /* finish handling expunges, so we don't break when updating
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
314 recent flags */
6956
f0dbbc1f0586 Code cleanup
Timo Sirainen <tss@iki.fi>
parents: 6955
diff changeset
315 while (index_mailbox_sync_next_expunge(ctx, &sync_rec) > 0) ;
6955
07f151520c84 Don't assert-crash if sync was aborted and it still had expunges left.
Timo Sirainen <tss@iki.fi>
parents: 6677
diff changeset
316
6279
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
317 if (ctx->sync_ctx != NULL) {
7815
2d62129a709b QRESYNC: If MODSEQs were returned in FETCH replies but there are pending
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
318 if (mail_index_view_sync_commit(&ctx->sync_ctx,
2d62129a709b QRESYNC: If MODSEQs were returned in FETCH replies but there are pending
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
319 &delayed_expunges) < 0) {
6673
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
320 mail_storage_set_index_error(ibox);
6279
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
321 ret = -1;
6673
c5e4a7b75586 Fixes to handling inconsistent views after index reset.
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
322 }
6279
f52e7d1402b5 mail_index_view_sync_next() and mailbox_sync_next() returns now bool.
Timo Sirainen <tss@iki.fi>
parents: 6275
diff changeset
323 }
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
324 index_mailbox_expunge_unseen_recent(ctx);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
325
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
326 if (ibox->keep_recent) {
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
327 /* mailbox syncing didn't necessarily update our recent state */
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
328 hdr = mail_index_get_header(ibox->view);
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
329 if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) {
6677
90bcf480312d Renamed mail_index_lookup_uid_range() to mail_index_lookup_seq_range(), made
Timo Sirainen <tss@iki.fi>
parents: 6676
diff changeset
330 mail_index_lookup_seq_range(ibox->view,
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
331 hdr->first_recent_uid,
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
332 hdr->next_uid,
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
333 &seq1, &seq2);
6037
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
334 if (seq1 != 0) {
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
335 index_mailbox_set_recent_seq(ibox, ibox->view,
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
336 seq1, seq2);
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
337 }
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
338 }
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
339 }
d911d943438e Recent flag handling rewrite. Still not perfect with maildir.
Timo Sirainen <tss@iki.fi>
parents: 5764
diff changeset
340
7815
2d62129a709b QRESYNC: If MODSEQs were returned in FETCH replies but there are pending
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
341 if (ret == 0 && status_items != 0) {
6275
913b188f4dd4 Removed explicit locking from views and maps. They were already locked all
Timo Sirainen <tss@iki.fi>
parents: 6103
diff changeset
342 mailbox_get_status(_ctx->box, status_items, status_r);
7815
2d62129a709b QRESYNC: If MODSEQs were returned in FETCH replies but there are pending
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
343 status_r->sync_delayed_expunges = delayed_expunges;
2d62129a709b QRESYNC: If MODSEQs were returned in FETCH replies but there are pending
Timo Sirainen <tss@iki.fi>
parents: 7798
diff changeset
344 }
327
276b7a53c264 Modify log fixes. STORE and SEARCH didn't handle properly message sequence
Timo Sirainen <tss@iki.fi>
parents: 325
diff changeset
345
7647
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7624
diff changeset
346 index_sync_search_results_update(ctx);
879208fdc7e3 Implemented CONTEXT=SEARCH extension.
Timo Sirainen <tss@iki.fi>
parents: 7624
diff changeset
347
7174
f090b6bf8021 Don't crash if sync initialization fails.
Timo Sirainen <tss@iki.fi>
parents: 7128
diff changeset
348 if (array_is_created(&ctx->flag_updates))
f090b6bf8021 Don't crash if sync initialization fails.
Timo Sirainen <tss@iki.fi>
parents: 7128
diff changeset
349 array_free(&ctx->flag_updates);
7887
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
350 if (array_is_created(&ctx->hidden_updates))
38bdfafa655c Search result update handling code cleanups.
Timo Sirainen <tss@iki.fi>
parents: 7875
diff changeset
351 array_free(&ctx->hidden_updates);
7888
3ffac3f6173f Moved non-syncing related search result updating code to a separate file and
Timo Sirainen <tss@iki.fi>
parents: 7887
diff changeset
352 if (array_is_created(&ctx->all_flag_updates_merge))
3ffac3f6173f Moved non-syncing related search result updating code to a separate file and
Timo Sirainen <tss@iki.fi>
parents: 7887
diff changeset
353 array_free(&ctx->all_flag_updates_merge);
2322
aae574ed7f4c Broke mailbox_sync() into iterator.
Timo Sirainen <tss@iki.fi>
parents: 2317
diff changeset
354 i_free(ctx);
600
3b44bc64afd4 mailbox_check_interval setting: Dovecot can notify client of new mail in
Timo Sirainen <tss@iki.fi>
parents: 570
diff changeset
355 return ret;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
356 }
3821
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
357
4451
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 4073
diff changeset
358 bool index_keyword_array_cmp(const ARRAY_TYPE(keyword_indexes) *k1,
1a35d53c18fc Array API redesigned to work using unions. It now provides type safety
Timo Sirainen <tss@iki.fi>
parents: 4073
diff changeset
359 const ARRAY_TYPE(keyword_indexes) *k2)
3821
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
360 {
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
361 const unsigned int *idx1, *idx2;
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
362 unsigned int i, j, count1, count2;
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
363
3834
3a03da46d884 Crashfix to last keyword compare update
Timo Sirainen <tss@iki.fi>
parents: 3825
diff changeset
364 if (!array_is_created(k1))
3a03da46d884 Crashfix to last keyword compare update
Timo Sirainen <tss@iki.fi>
parents: 3825
diff changeset
365 return !array_is_created(k2) || array_count(k2) == 0;
3a03da46d884 Crashfix to last keyword compare update
Timo Sirainen <tss@iki.fi>
parents: 3825
diff changeset
366 if (!array_is_created(k2))
3979
f209b3fc77e4 Keyword comparing still didn't work perfectly when there were no keywords.
Timo Sirainen <tss@iki.fi>
parents: 3879
diff changeset
367 return array_count(k1) == 0;
3834
3a03da46d884 Crashfix to last keyword compare update
Timo Sirainen <tss@iki.fi>
parents: 3825
diff changeset
368
3821
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
369 /* The arrays may not be sorted, but they usually are. Optimize for
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
370 the assumption that they are */
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
371 idx1 = array_get(k1, &count1);
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
372 idx2 = array_get(k2, &count2);
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
373
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
374 if (count1 != count2)
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
375 return FALSE;
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
376
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
377 for (i = 0; i < count1; i++) {
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
378 if (idx1[i] != idx2[i]) {
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
379 /* not found / unsorted array. check. */
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
380 for (j = 0; j < count1; j++) {
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
381 if (idx1[i] == idx2[j])
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
382 break;
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
383 }
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
384 if (j == count1)
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
385 return FALSE;
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
386 }
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
387 }
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
388 return TRUE;
c8b2ed2c9961 We assumed that keyword index arrays were always sorted. This isn't always
Timo Sirainen <tss@iki.fi>
parents: 3278
diff changeset
389 }
7128
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
390
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
391 enum mailbox_sync_type index_sync_type_convert(enum mail_index_sync_type type)
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
392 {
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
393 enum mailbox_sync_type ret = 0;
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
394
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
395 if ((type & MAIL_INDEX_SYNC_TYPE_EXPUNGE) != 0)
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
396 ret |= MAILBOX_SYNC_TYPE_EXPUNGE;
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
397 if ((type & (MAIL_INDEX_SYNC_TYPE_FLAGS |
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
398 MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD |
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
399 MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE |
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
400 MAIL_INDEX_SYNC_TYPE_KEYWORD_RESET)) != 0)
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
401 ret |= MAILBOX_SYNC_TYPE_FLAGS;
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
402 return ret;
98788fdcc3a6 When syncing a mailbox, sync the view internally first completely and just
Timo Sirainen <tss@iki.fi>
parents: 7086
diff changeset
403 }