commit 594e60bd7485be2d3f173a78a79f18d7037f7a6d Author: Oswald Buddenhagen <o...@users.sf.net> Date: Sat Feb 20 22:52:49 2021 +0100
make UIDVALIDITY recovery more strict about vanished messages in particular, this covers the case of a mailbox being replaced with an empty new one, which would subsequently lead to the opposite end being emptied as well, which would typically be undesired. also add plenty of comments. src/sync.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sync.c b/src/sync.c index 90e25ca..9804b7e 100644 --- a/src/sync.c +++ b/src/sync.c @@ -1365,6 +1365,7 @@ box_opened2( sync_vars_t *svars, int t ) for (t = 0; t < 2; t++) if (svars->uidval[t] != UIDVAL_BAD && svars->uidval[t] != svars->newuidval[t]) fails++; + // If only one side changed UIDVALIDITY, we will try to re-approve it further down. if (fails == 2) { error( "Error: channel %s: UIDVALIDITY of both far side %s and near side %s changed.\n", svars->chan->name, svars->orig_name[F], svars->orig_name[N]); @@ -1588,14 +1589,17 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux for (t = 0; t < 2; t++) { if (svars->uidval[t] != UIDVAL_BAD && svars->uidval[t] != svars->newuidval[t]) { + // This code checks whether the messages with known UIDs are actually the + // same messages, as recognized by their Message-IDs. unsigned need = 0, got = 0; debug( "trying to re-approve uid validity of %s\n", str_fn[t] ); for (srec = svars->srecs; srec; srec = srec->next) { if (srec->status & S_DEAD) continue; + need++; if (!srec->msg[t]) continue; // Message disappeared. - need++; // Present paired messages require re-validation. + // Present paired messages require re-validation. if (!srec->msg[t]->msgid) continue; // Messages without ID are useless for re-validation. if (!srec->msg[1-t]) @@ -1610,6 +1614,12 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux } got++; } + // We encountered no messages that contradict the hypothesis that the + // UIDVALIDITY change was spurious. + // If we got enough messages confirming the hypothesis, we just accept it. + // If there aren't quite enough messages, we check that at least 80% of + // those previously present are still there and confirm the hypothesis; + // this also covers the case of a box that was already empty. if (got < 20 && got * 5 < need * 4) { // Too few confirmed messages. This is very likely in the drafts folder. // A proper fallback would be fetching more headers (which potentially need _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel