re-nest conditions for trashing messages
this makes the logic easier to follow and document in place. also add some debug statements.
This commit is contained in:
parent
91d19cceac
commit
f7650993b7
111
src/sync.c
111
src/sync.c
|
@ -1534,6 +1534,7 @@ static void
|
||||||
msgs_flags_set( sync_vars_t *svars, int t )
|
msgs_flags_set( sync_vars_t *svars, int t )
|
||||||
{
|
{
|
||||||
message_t *tmsg;
|
message_t *tmsg;
|
||||||
|
sync_rec_t *srec;
|
||||||
trash_vars_t *tv;
|
trash_vars_t *tv;
|
||||||
copy_vars_t *cv;
|
copy_vars_t *cv;
|
||||||
|
|
||||||
|
@ -1542,53 +1543,75 @@ msgs_flags_set( sync_vars_t *svars, int t )
|
||||||
|
|
||||||
sync_ref( svars );
|
sync_ref( svars );
|
||||||
|
|
||||||
if ((svars->chan->ops[t] & OP_EXPUNGE) &&
|
if (!(svars->chan->ops[t] & OP_EXPUNGE))
|
||||||
(svars->ctx[t]->conf->trash || (svars->ctx[t^1]->conf->trash && svars->ctx[t^1]->conf->trash_remote_new))) {
|
goto skip;
|
||||||
debug( "trashing on %s\n", str_fn[t] );
|
int remote, only_new;
|
||||||
for (tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) {
|
if (svars->ctx[t]->conf->trash) {
|
||||||
if ((tmsg->flags & F_DELETED) && !find_uint_array( svars->trashed_msgs[t].array, tmsg->uid ) &&
|
only_new = svars->ctx[t]->conf->trash_only_new;
|
||||||
(t == F || !tmsg->srec || !(tmsg->srec->status & (S_EXPIRE|S_EXPIRED)))) {
|
debug( "trashing %s on %s locally\n", only_new ? "new" : "all", str_fn[t] );
|
||||||
if (svars->ctx[t]->conf->trash) {
|
remote = 0;
|
||||||
if (!svars->ctx[t]->conf->trash_only_new || !tmsg->srec || (tmsg->srec->status & (S_PENDING | S_SKIPPED))) {
|
} else if (svars->ctx[t^1]->conf->trash && svars->ctx[t^1]->conf->trash_remote_new) {
|
||||||
debug( "%s: trashing message %u\n", str_fn[t], tmsg->uid );
|
debug( "trashing new on %s remotely\n", str_fn[t] );
|
||||||
trash_total[t]++;
|
only_new = 1;
|
||||||
stats();
|
remote = 1;
|
||||||
svars->trash_pending[t]++;
|
} else {
|
||||||
tv = nfmalloc( sizeof(*tv) );
|
goto skip;
|
||||||
tv->aux = AUX;
|
}
|
||||||
tv->msg = tmsg;
|
for (tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) {
|
||||||
svars->drv[t]->trash_msg( svars->ctx[t], tmsg, msg_trashed, tv );
|
if (!(tmsg->flags & F_DELETED)) {
|
||||||
if (check_cancel( svars ))
|
//debug( " message %u is not deleted\n", tmsg->uid ); // Too noisy
|
||||||
goto out;
|
continue;
|
||||||
} else {
|
}
|
||||||
debug( "%s: not trashing message %u - not new\n", str_fn[t], tmsg->uid );
|
debugn( " message %u ", tmsg->uid );
|
||||||
}
|
if ((srec = tmsg->srec)) {
|
||||||
} else {
|
if (t == N && (srec->status & (S_EXPIRE | S_EXPIRED))) {
|
||||||
if (!tmsg->srec || (tmsg->srec->status & (S_PENDING | S_SKIPPED))) {
|
// Don't trash messages that are deleted only due to expiring.
|
||||||
if (tmsg->size <= svars->ctx[t^1]->conf->max_size) {
|
// However, this is an unlikely configuration to start with ...
|
||||||
debug( "%s: remote trashing message %u\n", str_fn[t], tmsg->uid );
|
debug( "is expired\n" );
|
||||||
trash_total[t]++;
|
continue;
|
||||||
stats();
|
}
|
||||||
svars->trash_pending[t]++;
|
if (only_new && !(srec->status & (S_PENDING | S_SKIPPED))) {
|
||||||
cv = nfmalloc( sizeof(*cv) );
|
debug( "is not new\n" );
|
||||||
cv->cb = msg_rtrashed;
|
continue;
|
||||||
cv->aux = INV_AUX;
|
|
||||||
cv->srec = NULL;
|
|
||||||
cv->msg = tmsg;
|
|
||||||
cv->minimal = 0;
|
|
||||||
copy_msg( cv );
|
|
||||||
if (check_cancel( svars ))
|
|
||||||
goto out;
|
|
||||||
} else {
|
|
||||||
debug( "%s: not remote trashing message %u - too big\n", str_fn[t], tmsg->uid );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug( "%s: not remote trashing message %u - not new\n", str_fn[t], tmsg->uid );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (find_uint_array( svars->trashed_msgs[t].array, tmsg->uid )) {
|
||||||
|
debug( "was already trashed\n" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!remote) {
|
||||||
|
debug( "- trashing\n" );
|
||||||
|
trash_total[t]++;
|
||||||
|
stats();
|
||||||
|
svars->trash_pending[t]++;
|
||||||
|
tv = nfmalloc( sizeof(*tv) );
|
||||||
|
tv->aux = AUX;
|
||||||
|
tv->msg = tmsg;
|
||||||
|
svars->drv[t]->trash_msg( svars->ctx[t], tmsg, msg_trashed, tv );
|
||||||
|
} else {
|
||||||
|
if (tmsg->size > svars->ctx[t^1]->conf->max_size) {
|
||||||
|
// This is questionable, as these messages are actually lost
|
||||||
|
// (no upgradable dummies here).
|
||||||
|
// However, this is an unlikely configuration to start with ...
|
||||||
|
debug( "is too big\n" );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
debug( "- trashing\n" );
|
||||||
|
trash_total[t]++;
|
||||||
|
stats();
|
||||||
|
svars->trash_pending[t]++;
|
||||||
|
cv = nfmalloc( sizeof(*cv) );
|
||||||
|
cv->cb = msg_rtrashed;
|
||||||
|
cv->aux = INV_AUX;
|
||||||
|
cv->srec = NULL;
|
||||||
|
cv->msg = tmsg;
|
||||||
|
cv->minimal = 0;
|
||||||
|
copy_msg( cv );
|
||||||
|
}
|
||||||
|
if (check_cancel( svars ))
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
skip:
|
||||||
svars->state[t] |= ST_SENT_TRASH;
|
svars->state[t] |= ST_SENT_TRASH;
|
||||||
sync_close( svars, t );
|
sync_close( svars, t );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user