backport: deal with UIDVALIDITY of 0 properly.
CCMAIL: skinner@destiny-denied.co.uk -REF: 20080822094543.GA3528@ugly.local
This commit is contained in:
parent
d2ccc93584
commit
d47cca7dd9
|
@ -817,7 +817,7 @@ static int
|
||||||
parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
|
parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
|
||||||
{
|
{
|
||||||
imap_t *imap = ctx->imap;
|
imap_t *imap = ctx->imap;
|
||||||
char *arg, *p;
|
char *arg, *earg, *p;
|
||||||
|
|
||||||
if (*s != '[')
|
if (*s != '[')
|
||||||
return RESP_OK; /* no response code */
|
return RESP_OK; /* no response code */
|
||||||
|
@ -829,7 +829,9 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
arg = next_arg( &s );
|
arg = next_arg( &s );
|
||||||
if (!strcmp( "UIDVALIDITY", arg )) {
|
if (!strcmp( "UIDVALIDITY", arg )) {
|
||||||
if (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg ))) {
|
if (!(arg = next_arg( &s )) ||
|
||||||
|
(ctx->gen.uidvalidity = strtoll( arg, &earg, 10 ), *earg))
|
||||||
|
{
|
||||||
fprintf( stderr, "IMAP error: malformed UIDVALIDITY status\n" );
|
fprintf( stderr, "IMAP error: malformed UIDVALIDITY status\n" );
|
||||||
return RESP_BAD;
|
return RESP_BAD;
|
||||||
}
|
}
|
||||||
|
@ -847,7 +849,8 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
|
||||||
for (; isspace( (unsigned char)*p ); p++);
|
for (; isspace( (unsigned char)*p ); p++);
|
||||||
fprintf( stderr, "*** IMAP ALERT *** %s\n", p );
|
fprintf( stderr, "*** IMAP ALERT *** %s\n", p );
|
||||||
} else if (cb && cb->ctx && !strcmp( "APPENDUID", arg )) {
|
} else if (cb && cb->ctx && !strcmp( "APPENDUID", arg )) {
|
||||||
if (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg )) ||
|
if (!(arg = next_arg( &s )) ||
|
||||||
|
(ctx->gen.uidvalidity = strtoll( arg, &earg, 10 ), *earg) ||
|
||||||
!(arg = next_arg( &s )) || !(*(int *)cb->ctx = atoi( arg )))
|
!(arg = next_arg( &s )) || !(*(int *)cb->ctx = atoi( arg )))
|
||||||
{
|
{
|
||||||
fprintf( stderr, "IMAP error: malformed APPENDUID status\n" );
|
fprintf( stderr, "IMAP error: malformed APPENDUID status\n" );
|
||||||
|
|
11
src/sync.c
11
src/sync.c
|
@ -474,7 +474,7 @@ sync_boxes( store_t *mctx, const char *mname,
|
||||||
|
|
||||||
nmmsg = nsmsg = 0;
|
nmmsg = nsmsg = 0;
|
||||||
|
|
||||||
mctx->uidvalidity = sctx->uidvalidity = 0;
|
mctx->uidvalidity = sctx->uidvalidity = -1;
|
||||||
mopts = sopts = 0;
|
mopts = sopts = 0;
|
||||||
makeopts( chan->sops, chan->slave, &sopts, chan->master, &mopts );
|
makeopts( chan->sops, chan->slave, &sopts, chan->master, &mopts );
|
||||||
makeopts( chan->mops, chan->master, &mopts, chan->slave, &sopts );
|
makeopts( chan->mops, chan->master, &mopts, chan->slave, &sopts );
|
||||||
|
@ -510,7 +510,8 @@ sync_boxes( store_t *mctx, const char *mname,
|
||||||
nfasprintf( &jname, "%s.journal", dname );
|
nfasprintf( &jname, "%s.journal", dname );
|
||||||
nfasprintf( &nname, "%s.new", dname );
|
nfasprintf( &nname, "%s.new", dname );
|
||||||
nfasprintf( &lname, "%s.lock", dname );
|
nfasprintf( &lname, "%s.lock", dname );
|
||||||
muidval = suidval = smaxxuid = mmaxuid = smaxuid = 0;
|
muidval = suidval = -1;
|
||||||
|
smaxxuid = mmaxuid = smaxuid = 0;
|
||||||
memset( &lck, 0, sizeof(lck) );
|
memset( &lck, 0, sizeof(lck) );
|
||||||
#if SEEK_SET != 0
|
#if SEEK_SET != 0
|
||||||
lck.l_whence = SEEK_SET;
|
lck.l_whence = SEEK_SET;
|
||||||
|
@ -705,7 +706,7 @@ sync_boxes( store_t *mctx, const char *mname,
|
||||||
info( "%d messages, %d recent\n", sctx->count, sctx->recent );
|
info( "%d messages, %d recent\n", sctx->count, sctx->recent );
|
||||||
dump_box( sctx );
|
dump_box( sctx );
|
||||||
|
|
||||||
if (suidval && suidval != sctx->uidvalidity) {
|
if (suidval >= 0 && suidval != sctx->uidvalidity) {
|
||||||
fprintf( stderr, "Error: UIDVALIDITY of slave changed\n" );
|
fprintf( stderr, "Error: UIDVALIDITY of slave changed\n" );
|
||||||
ret = SYNC_FAIL;
|
ret = SYNC_FAIL;
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -809,13 +810,13 @@ sync_boxes( store_t *mctx, const char *mname,
|
||||||
info( "%d messages, %d recent\n", mctx->count, mctx->recent );
|
info( "%d messages, %d recent\n", mctx->count, mctx->recent );
|
||||||
dump_box( mctx );
|
dump_box( mctx );
|
||||||
|
|
||||||
if (muidval && muidval != mctx->uidvalidity) {
|
if (muidval >= 0 && muidval != mctx->uidvalidity) {
|
||||||
fprintf( stderr, "Error: UIDVALIDITY of master changed\n" );
|
fprintf( stderr, "Error: UIDVALIDITY of master changed\n" );
|
||||||
ret = SYNC_FAIL;
|
ret = SYNC_FAIL;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!muidval || !suidval) {
|
if (muidval < 0 || suidval < 0) {
|
||||||
muidval = mctx->uidvalidity;
|
muidval = mctx->uidvalidity;
|
||||||
suidval = sctx->uidvalidity;
|
suidval = sctx->uidvalidity;
|
||||||
Fprintf( jfp, "| %d %d\n", muidval, suidval );
|
Fprintf( jfp, "| %d %d\n", muidval, suidval );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user