handle failure to store message. this helps with invalid messages like

0-byte files after crashes.
This commit is contained in:
Oswald Buddenhagen 2009-03-21 16:05:51 +00:00
parent b546877d70
commit 608a2863e0
2 changed files with 15 additions and 0 deletions

View File

@ -1586,6 +1586,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )
}
/* invalid message */
free( fmap );
fprintf( stderr, "IMAP warning: storing message with incomplete header.\n" );
return DRV_MSG_BAD;
mktid:
for (j = 0; j < TUIDL; j++)

View File

@ -301,6 +301,13 @@ sync_old( int tops, store_t *sctx, store_t *tctx, store_conf_t *tconf, FILE *jfp
case DRV_OK:
smsg->flags = msgdata.flags;
switch (tdriver->store_msg( tctx, &msgdata, &uid )) {
case DRV_MSG_BAD:
warn( pull ?
"Warning: Slave refuses to store message %d from master.\n" :
"Warning: Master refuses to store message %d from slave.\n",
smsg->uid );
smsg->status |= M_NOT_SYNCED;
break;
case DRV_STORE_BAD: return pull ? SYNC_SLAVE_BAD : SYNC_MASTER_BAD;
default: return SYNC_FAIL;
case DRV_OK:
@ -399,6 +406,13 @@ sync_new( int tops, store_t *sctx, store_t *tctx, store_conf_t *tconf, FILE *jfp
}
msg->flags = msgdata.flags;
switch (tdriver->store_msg( tctx, &msgdata, &uid )) {
case DRV_MSG_BAD:
warn( pull ?
"Warning: Slave refuses to store message %d from master.\n" :
"Warning: Master refuses to store message %d from slave.\n",
msg->uid );
msg->status |= M_NOT_SYNCED;
continue;
case DRV_STORE_BAD: return pull ? SYNC_SLAVE_BAD : SYNC_MASTER_BAD;
default: return SYNC_FAIL;
case DRV_OK: break;