don't record newuid in the sync state

this value is only ever used to find just pushed messages by TUID, so we
can simply use the UIDNEXT value from before we started pushing - and of
course, we need to record that in the journal. it makes no sense to log
the new value after completing a search, as there won't be a next search
before we push the next messages.
This commit is contained in:
Oswald Buddenhagen 2013-03-30 16:27:11 +01:00
parent 96be183acb
commit 9261897629
2 changed files with 8 additions and 9 deletions

View File

@ -367,7 +367,7 @@ sub showstate($)
close FILE; close FILE;
return; return;
} }
if (!/^1:(\d+):0 1:(\d+):(\d+):0\n$/) { if (!/^1:(\d+) 1:(\d+):(\d+)\n$/) {
print STDERR " Malformed sync state header '$_'.\n"; print STDERR " Malformed sync state header '$_'.\n";
close FILE; close FILE;
return; return;
@ -508,7 +508,7 @@ sub ckstate($@)
return 1; return 1;
} }
chomp($l); chomp($l);
my $xl = "1:".shift(@T).":0 1:".shift(@T).":".shift(@T).":0"; my $xl = "1:".shift(@T)." 1:".shift(@T).":".shift(@T);
if ($l ne $xl) { if ($l ne $xl) {
print STDERR "Sync state header mismatch: '$l' instead of '$xl'.\n"; print STDERR "Sync state header mismatch: '$l' instead of '$xl'.\n";
return 1; return 1;

View File

@ -725,8 +725,8 @@ box_selected( int sts, void *aux )
return; return;
} }
if (sscanf( buf, "%63s %63s", buf1, buf2 ) != 2 || if (sscanf( buf, "%63s %63s", buf1, buf2 ) != 2 ||
sscanf( buf1, "%d:%d:%d", &svars->uidval[M], &svars->maxuid[M], &svars->newuid[M] ) < 2 || sscanf( buf1, "%d:%d", &svars->uidval[M], &svars->maxuid[M] ) < 2 ||
sscanf( buf2, "%d:%d:%d:%d", &svars->uidval[S], &svars->smaxxuid, &svars->maxuid[S], &svars->newuid[S] ) < 3) { sscanf( buf2, "%d:%d:%d", &svars->uidval[S], &svars->smaxxuid, &svars->maxuid[S] ) < 3) {
error( "Error: invalid sync state header in %s\n", svars->dname ); error( "Error: invalid sync state header in %s\n", svars->dname );
goto jbail; goto jbail;
} }
@ -1045,7 +1045,6 @@ box_loaded( int sts, void *aux )
debug( "matching previously copied messages on %s\n", str_ms[t] ); debug( "matching previously copied messages on %s\n", str_ms[t] );
match_tuids( svars, t ); match_tuids( svars, t );
} }
Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext );
debug( "matching messages on %s against sync records\n", str_ms[t] ); debug( "matching messages on %s against sync records\n", str_ms[t] );
hashsz = bucketsForSize( svars->nsrecs * 3 ); hashsz = bucketsForSize( svars->nsrecs * 3 );
@ -1161,6 +1160,7 @@ box_loaded( int sts, void *aux )
debug( "synchronizing new entries\n" ); debug( "synchronizing new entries\n" );
svars->osrecadd = svars->srecadd; svars->osrecadd = svars->srecadd;
for (t = 0; t < 2; t++) { for (t = 0; t < 2; t++) {
Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext );
for (tmsg = svars->ctx[1-t]->msgs; tmsg; tmsg = tmsg->next) for (tmsg = svars->ctx[1-t]->msgs; tmsg; tmsg = tmsg->next)
if (tmsg->srec ? tmsg->srec->uid[t] < 0 && (tmsg->srec->uid[t] == -1 ? (svars->chan->ops[t] & OP_RENEW) : (svars->chan->ops[t] & OP_NEW)) : (svars->chan->ops[t] & OP_NEW)) { if (tmsg->srec ? tmsg->srec->uid[t] < 0 && (tmsg->srec->uid[t] == -1 ? (svars->chan->ops[t] & OP_RENEW) : (svars->chan->ops[t] & OP_NEW)) : (svars->chan->ops[t] & OP_NEW)) {
debug( "new message %d on %s\n", tmsg->uid, str_ms[1-t] ); debug( "new message %d on %s\n", tmsg->uid, str_ms[1-t] );
@ -1461,7 +1461,6 @@ msgs_found_new( int sts, void *aux )
static void static void
msgs_new_done( sync_vars_t *svars, int t ) msgs_new_done( sync_vars_t *svars, int t )
{ {
Fprintf( svars->jfp, "%c %d\n", "{}"[t], svars->ctx[t]->uidnext );
svars->state[t] |= ST_FOUND_NEW; svars->state[t] |= ST_FOUND_NEW;
sync_close( svars, t ); sync_close( svars, t );
} }
@ -1695,9 +1694,9 @@ box_closed_p2( sync_vars_t *svars, int t )
} }
} }
Fprintf( svars->nfp, "%d:%d:%d %d:%d:%d:%d\n", Fprintf( svars->nfp, "%d:%d %d:%d:%d\n",
svars->uidval[M], svars->maxuid[M], svars->ctx[M]->uidnext, svars->uidval[M], svars->maxuid[M],
svars->uidval[S], svars->smaxxuid, svars->maxuid[S], svars->ctx[S]->uidnext ); svars->uidval[S], svars->smaxxuid, svars->maxuid[S] );
for (srec = svars->srecs; srec; srec = srec->next) { for (srec = svars->srecs; srec; srec = srec->next) {
if (srec->status & S_DEAD) if (srec->status & S_DEAD)
continue; continue;