Browse Source

de-duplicate updating of uid in sync records

1.4
Oswald Buddenhagen 5 years ago
parent
commit
fd7b5659ab
  1. 42
      src/sync.c

42
src/sync.c

@ -244,6 +244,22 @@ jFprintf( sync_vars_t *svars, const char *msg, ... )
#define JLOG_SEL(_1, _2, _3, _4, x, ...) x #define JLOG_SEL(_1, _2, _3, _4, x, ...) x
#define JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(__VA_ARGS__) #define JLOG(...) JLOG_SEL(__VA_ARGS__, JLOG4, JLOG3, NO_JLOG2, NO_JLOG1)(__VA_ARGS__)
static void
assign_uid( sync_vars_t *svars, sync_rec_t *srec, int t, uint uid )
{
srec->uid[t] = uid;
if (uid == svars->maxuid[t] + 1)
svars->maxuid[t] = uid;
srec->status &= ~S_PENDING;
srec->tuid[0] = 0;
}
#define ASSIGN_UID(srec, t, nuid, ...) \
do { \
JLOG( "%c %u %u %u", ("<>"[t], srec->uid[F], srec->uid[N], nuid), __VA_ARGS__ ); \
assign_uid( svars, srec, t, nuid ); \
} while (0)
static void static void
match_tuids( sync_vars_t *svars, int t, message_t *msgs ) match_tuids( sync_vars_t *svars, int t, message_t *msgs )
{ {
@ -279,15 +295,10 @@ match_tuids( sync_vars_t *svars, int t, message_t *msgs )
num_lost++; num_lost++;
continue; continue;
mfound: mfound:
JLOG( "%c %u %u %u", ("<>"[t], srec->uid[F], srec->uid[N], tmsg->uid), "TUID matched %s", diag );
tmsg->srec = srec; tmsg->srec = srec;
srec->msg[t] = tmsg; srec->msg[t] = tmsg;
ntmsg = tmsg->next; ntmsg = tmsg->next;
srec->uid[t] = tmsg->uid; ASSIGN_UID( srec, t, tmsg->uid, "TUID matched %s", diag );
if (tmsg->uid == svars->maxuid[t] + 1)
svars->maxuid[t] = tmsg->uid;
srec->status = 0;
srec->tuid[0] = 0;
} }
} }
if (num_lost) if (num_lost)
@ -944,19 +955,11 @@ load_state( sync_vars_t *svars )
break; break;
case '<': case '<':
debug( "far side now %u\n", t3 ); debug( "far side now %u\n", t3 );
srec->uid[F] = t3; assign_uid( svars, srec, F, t3 );
if (t3 == svars->maxuid[F] + 1)
svars->maxuid[F] = t3;
srec->status &= ~S_PENDING;
srec->tuid[0] = 0;
break; break;
case '>': case '>':
debug( "near side now %u\n", t3 ); debug( "near side now %u\n", t3 );
srec->uid[N] = t3; assign_uid( svars, srec, N, t3 );
if (t3 == svars->maxuid[N] + 1)
svars->maxuid[N] = t3;
srec->status &= ~S_PENDING;
srec->tuid[0] = 0;
break; break;
case '*': case '*':
debug( "flags now %u\n", t3 ); debug( "flags now %u\n", t3 );
@ -1851,12 +1854,7 @@ msg_copied( int sts, uint uid, copy_vars_t *vars )
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 {
JLOG( "%c %u %u %u", ("<>"[t], srec->uid[F], srec->uid[N], uid), "%sed message", str_hl[t] ); ASSIGN_UID( srec, t, uid, "%sed message", str_hl[t] );
vars->srec->uid[t] = uid;
if (uid == svars->maxuid[t] + 1)
svars->maxuid[t] = uid;
vars->srec->status &= ~S_PENDING;
vars->srec->tuid[0] = 0;
} }
break; break;
case SYNC_NOGOOD: case SYNC_NOGOOD:

Loading…
Cancel
Save