re-nest conditions for syncing new messages
this makes the logic easier to follow and document in place. also, make the comments actually match reality.
This commit is contained in:
parent
ceb09fcd44
commit
8df1f5dd64
50
src/sync.c
50
src/sync.c
|
@ -1572,14 +1572,9 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
|
|||
}
|
||||
}
|
||||
|
||||
debug( "synchronizing new entries\n" );
|
||||
for (t = 0; t < 2; t++) {
|
||||
debug( "synchronizing new messages on %s\n", str_fn[1-t] );
|
||||
for (tmsg = svars->msgs[1-t]; tmsg; tmsg = tmsg->next) {
|
||||
// If new have no srec, the message is always New. If we have a srec:
|
||||
// - message is paired or expired => ignore
|
||||
// - message was skipped => ReNew
|
||||
// - message was attempted, but is still pending or failed => New
|
||||
//
|
||||
// If messages were previously ignored due to being excessive, they would now
|
||||
// appear to be newer than the messages that got actually synced, so increment
|
||||
// newmaxuid immediately to make sure we always look only at the newest ones.
|
||||
|
@ -1588,22 +1583,43 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
|
|||
// in case of interruption - in particular skipping big messages would otherwise
|
||||
// up the limit too early.
|
||||
srec = tmsg->srec;
|
||||
if (srec ? (((srec->status & S_PENDING) && (svars->chan->ops[t] & OP_NEW)) ||
|
||||
((srec->status & S_SKIPPED) && (svars->chan->ops[t] & OP_RENEW)))
|
||||
: svars->newmaxuid[1-t] < tmsg->uid && (svars->chan->ops[t] & OP_NEW)) {
|
||||
debug( "new message %u on %s\n", tmsg->uid, str_fn[1-t] );
|
||||
if ((svars->chan->ops[t] & OP_EXPUNGE) && (tmsg->flags & F_DELETED)) {
|
||||
if (srec) {
|
||||
if (srec->status & S_SKIPPED) {
|
||||
// The message was skipped due to being too big.
|
||||
if (!(svars->chan->ops[t] & OP_RENEW))
|
||||
continue;
|
||||
} else {
|
||||
if (!(svars->chan->ops[t] & OP_NEW))
|
||||
continue;
|
||||
if (!(srec->status & S_PENDING))
|
||||
continue; // Nothing to do - the message is paired or expired
|
||||
// Propagation was scheduled, but we got interrupted
|
||||
}
|
||||
debug( "unpropagated old message %u\n", tmsg->uid );
|
||||
|
||||
if ((svars->chan->ops[t] & OP_EXPUNGE) && (tmsg->flags & F_DELETED)) {
|
||||
JLOG( "- %u %u", (srec->uid[F], srec->uid[N]), "killing - would be expunged anyway" );
|
||||
tmsg->srec = NULL;
|
||||
srec->status = S_DEAD;
|
||||
} else {
|
||||
debug( "-> ignoring - would be expunged anyway\n" );
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (srec) {
|
||||
debug( "-> pair(%u,%u) exists\n", srec->uid[F], srec->uid[N] );
|
||||
} else {
|
||||
if (!(svars->chan->ops[t] & OP_NEW))
|
||||
continue;
|
||||
if (tmsg->uid <= svars->newmaxuid[1-t]) {
|
||||
// The message should be already paired. It's not, so it was:
|
||||
// - previously paired, but the entry was expired and pruned => ignore
|
||||
// - attempted, but failed => ignore (the wisdom of this is debatable)
|
||||
// - ignored, as it would have been expunged anyway => ignore (even if undeleted)
|
||||
continue;
|
||||
}
|
||||
debug( "new message %u\n", tmsg->uid );
|
||||
|
||||
if ((svars->chan->ops[t] & OP_EXPUNGE) && (tmsg->flags & F_DELETED)) {
|
||||
debug( "-> ignoring - would be expunged anyway\n" );
|
||||
continue;
|
||||
}
|
||||
|
||||
srec = nfcalloc( sizeof(*srec) );
|
||||
*svars->srecadd = srec;
|
||||
svars->srecadd = &srec->next;
|
||||
|
@ -1631,8 +1647,6 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((svars->chan->ops[N] & (OP_NEW|OP_RENEW|OP_FLAGS)) && svars->chan->max_messages) {
|
||||
// Note: When this branch is entered, we have loaded all near side messages.
|
||||
|
|
Loading…
Reference in New Issue
Block a user