From 3d90507a759e81bc5c3e116a3751f34657aa023b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 7 Feb 2022 20:01:03 +0100 Subject: [PATCH] fix resuming propagation of flags on new messages log the flags as soon as we know them, and commit them when the uid is assigned (including during tuid matching). amends 25b1c2b9. --- src/run-tests.pl | 20 ++++++++++---------- src/sync.c | 14 ++++++++------ src/sync_state.c | 9 +++++++++ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 5bb04f6..fceb5c2 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -950,7 +950,7 @@ my @x01 = ( G, "*F", "*", "_", H, "*FT", "*", "*", I, "_", "*", "*", - K, "*", "", "", + K, "*P", "", "", M, "", "", "*", ); @@ -965,7 +965,7 @@ my @X01 = ( H, "", "+FT", "+FT", I, "", "<", "+T", M, "*", "*", "", - K, "", "*", "*", + K, "", "*P", "*P", ); test("full", \@x01, \@X01, \@O01); @@ -980,7 +980,7 @@ my @X02 = ( H, "/", "/", "/", I, "", "/", "/", M, "*", "*", "", - K, "", "*", "*", + K, "", "*P", "*P", ); test("full + expunge both", \@x01, \@X02, \@O02); @@ -995,7 +995,7 @@ my @X03 = ( H, "", ">+T", "/", I, "", "/", "/", M, "*", "*", "", - K, "", "*", "*", + K, "", "*P", "*P", ); test("full + expunge near side", \@x01, \@X03, \@O03); @@ -1007,7 +1007,7 @@ my @X04 = ( E, "", "+T", "+T", H, "", "+FT", "+FT", I, "", "<", "+T", - K, "", "*", "*", + K, "", "*P", "*P", ); test("pull", \@x01, \@X04, \@O04); @@ -1034,7 +1034,7 @@ my @O07 = ("", "", "Sync New\n"); my @X07 = ( M, 0, K, M, "*", "*", "", - K, "", "*", "*", + K, "", "*P", "*P", ); test("new", \@x01, \@X07, \@O07); @@ -1052,7 +1052,7 @@ test("push flags + pull deletions", \@x01, \@X08, \@O08); my @x20 = ( 0, 0, 0, A, "*", "", "", - B, "**", "", "", + B, "*P*", "", "", C, "", "", "**", ); @@ -1061,7 +1061,7 @@ my @X21 = ( C, 0, B, C, "*?", "*<", "", A, "", "*", "*", - B, "", "*>", "*?", + B, "", "*>P", "*P?", ); test("max size", \@x20, \@X21, \@O21); @@ -1102,13 +1102,13 @@ my @x24 = ( C, 0, A, A, "*", "*", "*", B, "**", "*^", "", - C, "*F*", "*^", "", + C, "*FP*", "*^", "", ); my @X24 = ( C, 0, C, B, "", ">-^+>", "*?", - C, "", ">-^+F", "*F*", + C, "", ">-^+FP", "*FP*", ); test("max size (pre-1.4 legacy)", \@x24, \@X24, \@O21); diff --git a/src/sync.c b/src/sync.c index 71136aa..4099742 100644 --- a/src/sync.c +++ b/src/sync.c @@ -289,7 +289,14 @@ msg_fetched( int sts, void *aux ) return; } - vars->msg->flags = vars->data.flags = sanitize_flags( vars->data.flags, svars, t ); + vars->data.flags = sanitize_flags( vars->data.flags, svars, t ); + if (srec && !(srec->status & S_UPGRADE)) { + if (vars->data.flags) { + srec->pflags = vars->data.flags; + JLOG( "%% %u %u %u", (srec->uid[F], srec->uid[N], srec->pflags), + "%sing with flags %s", (str_hl[t], fmt_lone_flags( srec->pflags ).str) ); + } + } scr = svars->can_crlf[t^1]; tcr = svars->can_crlf[t]; @@ -1405,11 +1412,6 @@ msg_copied( int sts, uint uid, copy_vars_t *vars ) sync_rec_t *srec = vars->srec; switch (sts) { case SYNC_OK: - if (!(srec->status & S_UPGRADE) && vars->msg->flags != srec->flags) { - srec->flags = vars->msg->flags; - JLOG( "* %u %u %u", (srec->uid[F], srec->uid[N], srec->flags), - "%sed with flags %s", (str_hl[t], fmt_lone_flags( srec->flags ).str) ); - } if (!uid) // Stored to a non-UIDPLUS mailbox svars->state[t] |= ST_FIND_NEW; else diff --git a/src/sync_state.c b/src/sync_state.c index 3e4d2cd..82cc5f1 100644 --- a/src/sync_state.c +++ b/src/sync_state.c @@ -306,6 +306,7 @@ load_state( sync_vars_t *svars ) case '<': case '>': case '*': + case '%': case '~': bad = sscanf( buf + 2, "%u %u %u", &t1, &t2, &t3 ) != 3; break; @@ -393,6 +394,10 @@ load_state( sync_vars_t *svars ) srec->aflags[F] = srec->aflags[N] = 0; // Clear F_DELETED srec->status = (srec->status & ~S_PURGE) | S_PURGED; break; + case '%': + srec->pflags = (uchar)t3; + debug( "pending flags now %s\n", fmt_lone_flags( t3 ).str ); + break; case '~': srec->status = (srec->status & ~S_LOGGED) | t3; if ((srec->status & S_EXPIRED) && svars->maxxfuid < srec->uid[F]) @@ -516,6 +521,10 @@ assign_uid( sync_vars_t *svars, sync_rec_t *srec, int t, uint uid ) srec->uid[t] = uid; if (uid == svars->newmaxuid[t] + 1) svars->newmaxuid[t] = uid; + if (uid) { + if (!(srec->status & S_UPGRADE)) + srec->flags = srec->pflags; + } srec->status &= ~(S_PENDING | S_UPGRADE); srec->tuid[0] = 0; }