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", "*", "_",
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);

14
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

9
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;
}

Loading…
Cancel
Save