From 608a2863e04c8b14ef9a03e48db4fdd0c55ceaab Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 21 Mar 2009 16:05:51 +0000 Subject: [PATCH] handle failure to store message. this helps with invalid messages like 0-byte files after crashes. --- src/drv_imap.c | 1 + src/sync.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/drv_imap.c b/src/drv_imap.c index 9520cdd..dbdb1b1 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -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++) diff --git a/src/sync.c b/src/sync.c index 59035b6..5a5d247 100644 --- a/src/sync.c +++ b/src/sync.c @@ -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;