Browse Source

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.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
3d90507a75
  1. 20
      src/run-tests.pl
  2. 14
      src/sync.c
  3. 9
      src/sync_state.c

20
src/run-tests.pl

@ -950,7 +950,7 @@ my @x01 = (
G, "*F", "*", "_", G, "*F", "*", "_",
H, "*FT", "*", "*", H, "*FT", "*", "*",
I, "_", "*", "*", I, "_", "*", "*",
K, "*", "", "", K, "*P", "", "",
M, "", "", "*", M, "", "", "*",
); );
@ -965,7 +965,7 @@ my @X01 = (
H, "", "+FT", "+FT", H, "", "+FT", "+FT",
I, "", "<", "+T", I, "", "<", "+T",
M, "*", "*", "", M, "*", "*", "",
K, "", "*", "*", K, "", "*P", "*P",
); );
test("full", \@x01, \@X01, \@O01); test("full", \@x01, \@X01, \@O01);
@ -980,7 +980,7 @@ my @X02 = (
H, "/", "/", "/", H, "/", "/", "/",
I, "", "/", "/", I, "", "/", "/",
M, "*", "*", "", M, "*", "*", "",
K, "", "*", "*", K, "", "*P", "*P",
); );
test("full + expunge both", \@x01, \@X02, \@O02); test("full + expunge both", \@x01, \@X02, \@O02);
@ -995,7 +995,7 @@ my @X03 = (
H, "", ">+T", "/", H, "", ">+T", "/",
I, "", "/", "/", I, "", "/", "/",
M, "*", "*", "", M, "*", "*", "",
K, "", "*", "*", K, "", "*P", "*P",
); );
test("full + expunge near side", \@x01, \@X03, \@O03); test("full + expunge near side", \@x01, \@X03, \@O03);
@ -1007,7 +1007,7 @@ my @X04 = (
E, "", "+T", "+T", E, "", "+T", "+T",
H, "", "+FT", "+FT", H, "", "+FT", "+FT",
I, "", "<", "+T", I, "", "<", "+T",
K, "", "*", "*", K, "", "*P", "*P",
); );
test("pull", \@x01, \@X04, \@O04); test("pull", \@x01, \@X04, \@O04);
@ -1034,7 +1034,7 @@ my @O07 = ("", "", "Sync New\n");
my @X07 = ( my @X07 = (
M, 0, K, M, 0, K,
M, "*", "*", "", M, "*", "*", "",
K, "", "*", "*", K, "", "*P", "*P",
); );
test("new", \@x01, \@X07, \@O07); test("new", \@x01, \@X07, \@O07);
@ -1052,7 +1052,7 @@ test("push flags + pull deletions", \@x01, \@X08, \@O08);
my @x20 = ( my @x20 = (
0, 0, 0, 0, 0, 0,
A, "*", "", "", A, "*", "", "",
B, "**", "", "", B, "*P*", "", "",
C, "", "", "**", C, "", "", "**",
); );
@ -1061,7 +1061,7 @@ my @X21 = (
C, 0, B, C, 0, B,
C, "*?", "*<", "", C, "*?", "*<", "",
A, "", "*", "*", A, "", "*", "*",
B, "", "*>", "*?", B, "", "*>P", "*P?",
); );
test("max size", \@x20, \@X21, \@O21); test("max size", \@x20, \@X21, \@O21);
@ -1102,13 +1102,13 @@ my @x24 = (
C, 0, A, C, 0, A,
A, "*", "*", "*", A, "*", "*", "*",
B, "**", "*^", "", B, "**", "*^", "",
C, "*F*", "*^", "", C, "*FP*", "*^", "",
); );
my @X24 = ( my @X24 = (
C, 0, C, C, 0, C,
B, "", ">-^+>", "*?", B, "", ">-^+>", "*?",
C, "", ">-^+F", "*F*", C, "", ">-^+FP", "*FP*",
); );
test("max size (pre-1.4 legacy)", \@x24, \@X24, \@O21); test("max size (pre-1.4 legacy)", \@x24, \@X24, \@O21);

14
src/sync.c

@ -289,7 +289,14 @@ msg_fetched( int sts, void *aux )
return; 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]; scr = svars->can_crlf[t^1];
tcr = svars->can_crlf[t]; 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; sync_rec_t *srec = vars->srec;
switch (sts) { switch (sts) {
case SYNC_OK: 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 if (!uid) // Stored to a non-UIDPLUS mailbox
svars->state[t] |= ST_FIND_NEW; svars->state[t] |= ST_FIND_NEW;
else else

9
src/sync_state.c

@ -306,6 +306,7 @@ load_state( sync_vars_t *svars )
case '<': case '<':
case '>': case '>':
case '*': case '*':
case '%':
case '~': case '~':
bad = sscanf( buf + 2, "%u %u %u", &t1, &t2, &t3 ) != 3; bad = sscanf( buf + 2, "%u %u %u", &t1, &t2, &t3 ) != 3;
break; break;
@ -393,6 +394,10 @@ load_state( sync_vars_t *svars )
srec->aflags[F] = srec->aflags[N] = 0; // Clear F_DELETED srec->aflags[F] = srec->aflags[N] = 0; // Clear F_DELETED
srec->status = (srec->status & ~S_PURGE) | S_PURGED; srec->status = (srec->status & ~S_PURGE) | S_PURGED;
break; break;
case '%':
srec->pflags = (uchar)t3;
debug( "pending flags now %s\n", fmt_lone_flags( t3 ).str );
break;
case '~': case '~':
srec->status = (srec->status & ~S_LOGGED) | t3; srec->status = (srec->status & ~S_LOGGED) | t3;
if ((srec->status & S_EXPIRED) && svars->maxxfuid < srec->uid[F]) 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; srec->uid[t] = uid;
if (uid == svars->newmaxuid[t] + 1) if (uid == svars->newmaxuid[t] + 1)
svars->newmaxuid[t] = uid; svars->newmaxuid[t] = uid;
if (uid) {
if (!(srec->status & S_UPGRADE))
srec->flags = srec->pflags;
}
srec->status &= ~(S_PENDING | S_UPGRADE); srec->status &= ~(S_PENDING | S_UPGRADE);
srec->tuid[0] = 0; srec->tuid[0] = 0;
} }

Loading…
Cancel
Save