Skip to content

Commit

Permalink
Merge pull request #4851 from cyrusimap/xconvmodseq-noreplica
Browse files Browse the repository at this point in the history
conversations: don't update xconvmodseq on replicas
  • Loading branch information
brong committed Mar 19, 2024
2 parents 6768f3e + ed32744 commit be968c3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
33 changes: 22 additions & 11 deletions cunit/conversations.testc
Expand Up @@ -412,7 +412,8 @@ static void test_folder_rename(void)
&ecounts1,
/*size*/10, /*counts*/NULL,
/*modseq*/1,
/*createdmodseq*/1);
/*createdmodseq*/1,
/*silent*/0);

int f2 = conversation_folder_number(state, FOLDER2, 1);
struct emailcounts ecounts2 = { f2, 0, -1, { 0, 0, 0, 0, 0, 0 }, { 1, 1, 0, 1, 1, 0 },
Expand All @@ -422,7 +423,8 @@ static void test_folder_rename(void)
&ecounts2,
/*size*/20, /*counts*/NULL,
/*modseq*/8,
/*createdmodseq*/1);
/*createdmodseq*/1,
/*silent*/0);

conv->subject = xstrdup("☃");

Expand Down Expand Up @@ -526,7 +528,8 @@ static void test_folders(void)
&ecounts1,
/*size*/0, counts,
/*modseq*/4,
/*createdmodseq*/1);
/*createdmodseq*/1,
/*silent*/0);

/* make sure the data we just passed to conversation_update()
* is present in the structure */
Expand Down Expand Up @@ -594,7 +597,8 @@ static void test_folders(void)
&ecounts2,
/*size*/0, counts,
/*modseq*/7,
/*createdmodseq*/1);
/*createdmodseq*/1,
/*silent*/0);

CU_ASSERT_EQUAL((conv->flags & CONV_ISDIRTY), CONV_ISDIRTY);
CU_ASSERT_EQUAL(conv->num_records, 2);
Expand Down Expand Up @@ -630,7 +634,8 @@ static void test_folders(void)
&ecounts3,
/*size*/0, counts,
/*modseq*/55,
/*createdmodseq*/1);
/*createdmodseq*/1,
/*silent*/0);

CU_ASSERT_EQUAL((conv->flags & CONV_ISDIRTY), CONV_ISDIRTY);
CU_ASSERT_EQUAL(conv->num_records, 3);
Expand Down Expand Up @@ -750,7 +755,8 @@ static void test_folders(void)
&ecountsneg1,
/*size*/0, counts,
/*modseq*/56,
/*createdmodseq*/1);
/*createdmodseq*/1,
/*silent*/0);

CU_ASSERT_EQUAL(conv->num_records, 2);
CU_ASSERT_EQUAL(conv->exists, 1);
Expand Down Expand Up @@ -866,7 +872,8 @@ static void test_folder_ordering(void)
&ecounts1,
/*size*/0, counts,
/*modseq*/1,
/*createdmodseq*/0);
/*createdmodseq*/0,
/*silent*/0);

/* add folders out of order */
struct emailcounts ecounts3 = { f3, 0, -1, { 0, 0, 0, 0, 0, 0 }, { 1, 1, 0, 1, 1, 0 },
Expand All @@ -875,7 +882,8 @@ static void test_folder_ordering(void)
&ecounts3,
/*size*/0, counts,
/*modseq*/55,
/*createdmodseq*/0);
/*createdmodseq*/0,
/*silent*/0);

/* save and reload here just to be sure */
r = conversation_save(state, C_CID, conv);
Expand All @@ -892,7 +900,8 @@ static void test_folder_ordering(void)
&ecounts2,
/*size*/0, counts,
/*modseq*/7,
/*createdmodseq*/0);
/*createdmodseq*/0,
/*silent*/0);

CU_ASSERT_EQUAL((conv->flags & CONV_ISDIRTY), CONV_ISDIRTY);

Expand Down Expand Up @@ -1019,7 +1028,8 @@ static void __test_senders(void)
/*exists*/1, /*unseen*/0,
/*size*/0, counts,
/*modseq*/1,
/*createdmodseq*/0);
/*createdmodseq*/0,
/*silent*/0);

/* there's no function for getting sender data, oh well */
sender1 = conv->senders;
Expand Down Expand Up @@ -1215,7 +1225,8 @@ static void test_dump(void)
&ecounts,
/*size*/0, /*counts*/NULL,
/*modseq*/100,
/*createdmodseq*/0);
/*createdmodseq*/0,
/*silent*/0);
}
r = conversation_save(state, cid, conv);
CU_ASSERT_EQUAL(r, 0);
Expand Down
17 changes: 9 additions & 8 deletions imap/conversations.c
Expand Up @@ -144,7 +144,7 @@ static char *conversations_path(mbname_t *mbname)
return NULL;
// deleted mailboxes don't have a conversations database
if (mbname_isdeleted(mbname))
return NULL;
return NULL;
if (convdir)
return strconcat(convdir, "/", mbname_userid(mbname), ".", suff, (char *)NULL);
return mboxname_conf_getpath(mbname, suff);
Expand Down Expand Up @@ -1818,7 +1818,7 @@ static void conversations_thread_sort(conversation_t *conv)
static void conversation_update_thread(conversation_t *conv,
const struct message_guid *guid,
time_t internaldate,
modseq_t createdmodseq,
modseq_t createdmodseq,
int delta_exists)
{
conv_thread_t *thread, **nextp = &conv->thread;
Expand Down Expand Up @@ -2436,7 +2436,8 @@ EXPORTED int conversations_update_record(struct conversations_state *cstate,
const struct index_record *old,
struct index_record *new,
int allowrenumber,
int ignorelimits)
int ignorelimits,
int silent)
{
conversation_t *conv = NULL;
size_t delta_exists = 0;
Expand All @@ -2460,9 +2461,9 @@ EXPORTED int conversations_update_record(struct conversations_state *cstate,
* a removal and re-add, so cache gets parsed and msgids
* updated */
if (old->cid != new->cid) {
r = conversations_update_record(cstate, mailbox, old, NULL, 0, ignorelimits);
r = conversations_update_record(cstate, mailbox, old, NULL, 0, ignorelimits, silent);
if (r) return r;
return conversations_update_record(cstate, mailbox, NULL, new, 0, ignorelimits);
return conversations_update_record(cstate, mailbox, NULL, new, 0, ignorelimits, silent);
}
}

Expand Down Expand Up @@ -2637,7 +2638,7 @@ EXPORTED int conversations_update_record(struct conversations_state *cstate,

r = conversation_update(cstate, conv, &ecounts,
delta_size, delta_counts,
modseq, record->createdmodseq);
modseq, record->createdmodseq, silent);
if (r) goto done;

r = conversation_save(cstate, record->cid, conv);
Expand All @@ -2653,7 +2654,7 @@ EXPORTED int conversations_update_record(struct conversations_state *cstate,
EXPORTED int conversation_update(struct conversations_state *state,
conversation_t *conv, struct emailcounts *ecounts,
ssize_t delta_size, int *delta_counts,
modseq_t modseq, modseq_t createdmodseq)
modseq_t modseq, modseq_t createdmodseq, int silent)
{
conv_folder_t *folder = conversation_get_folder(conv, ecounts->foldernum, /*create*/1);

Expand Down Expand Up @@ -2832,7 +2833,7 @@ EXPORTED int conversation_update(struct conversations_state *state,

}

if (status.threadmodseq < modseq) {
if (!silent && status.threadmodseq < modseq) {
status.threadmodseq = modseq;
dirty = 1;
}
Expand Down
5 changes: 3 additions & 2 deletions imap/conversations.h
Expand Up @@ -330,13 +330,14 @@ extern int conversations_update_record(struct conversations_state *cstate,
const struct index_record *old,
struct index_record *new_,
int allowrenumber,
int ignorelimits);
int ignorelimits,
int silent);

extern int conversation_update(struct conversations_state *state,
conversation_t *conv,
struct emailcounts *ecounts,
ssize_t delta_size, int *delta_counts,
modseq_t modseq, modseq_t createdmodseq);
modseq_t modseq, modseq_t createdmodseq, int silent);
extern conv_folder_t *conversation_find_folder(struct conversations_state *state,
conversation_t *,
const char *mboxname);
Expand Down
11 changes: 6 additions & 5 deletions imap/mailbox.c
Expand Up @@ -4345,7 +4345,7 @@ static int mailbox_update_conversations(struct mailbox *mailbox,

int ignorelimits = new ? new->ignorelimits : 1;
return conversations_update_record(cstate, mailbox, old, new,
/*allowrenumber*/1, ignorelimits);
/*allowrenumber*/1, ignorelimits, mailbox->silentchanges);
}


Expand Down Expand Up @@ -6103,7 +6103,7 @@ EXPORTED int mailbox_add_conversations(struct mailbox *mailbox, int silent)
struct index_record copyrecord = *record;
copyrecord.silentupdate = silent;
r = conversations_update_record(cstate, mailbox, NULL, &copyrecord, 1,
/*ignorelimits*/1);
/*ignorelimits*/1, silent);
if (r) break;

if (copyrecord.cid == record->cid)
Expand All @@ -6113,15 +6113,15 @@ EXPORTED int mailbox_add_conversations(struct mailbox *mailbox, int silent)

/* remove this record again */
r = conversations_update_record(cstate, mailbox, &copyrecord, NULL, 0,
/*ignorelimits*/1);
/*ignorelimits*/1, silent);
if (r) break;

/* we had a cid change, so rewrite will try to correct the counts, so we
* need to add this one in again */
struct index_record oldrecord = *record;
/* add the old record that's going away */
r = conversations_update_record(cstate, mailbox, NULL, &oldrecord, 0,
/*ignorelimits*/1);
/*ignorelimits*/1, silent);
if (r) break;

/* and finally to the update that will reverse those two actions again */
Expand Down Expand Up @@ -6149,7 +6149,8 @@ static int mailbox_delete_conversations(struct mailbox *mailbox)
continue;

r = conversations_update_record(cstate, mailbox, record, NULL,
/*allowrenumber*/0, /*ignorelimits*/1);
/*allowrenumber*/0, /*ignorelimits*/1,
mailbox->silentchanges);
if (r) break;
}
mailbox_iter_done(&iter);
Expand Down

0 comments on commit be968c3

Please sign in to comment.