# HG changeset patch # User Timo Sirainen # Date 1112912538 -10800 # Node ID 98e3001ca527cd6fa4216528fbc3cef523451356 # Parent fb34cde02ac8daafb9f77945d61666ba59dca925 Added mail_index_sync_reset() to restart syncing from beginning. diff -r fb34cde02ac8 -r 98e3001ca527 src/lib-index/mail-index-sync.c --- a/src/lib-index/mail-index-sync.c Fri Apr 08 01:09:07 2005 +0300 +++ b/src/lib-index/mail-index-sync.c Fri Apr 08 01:22:18 2005 +0300 @@ -498,7 +498,7 @@ /* FIXME: replace with a priority queue so we don't have to go through the whole list constantly. and remember to make sure that keyword resets are sent before adds! */ - sync_list = array_get(&ctx->sync_list, &count); + sync_list = array_get_modifyable(&ctx->sync_list, &count); for (i = 0; i < count; i++) { if (!array_is_created(sync_list[i].array) || sync_list[i].idx == array_count(sync_list[i].array)) @@ -568,6 +568,18 @@ return FALSE; } +void mail_index_sync_reset(struct mail_index_sync_ctx *ctx) +{ + struct mail_index_sync_list *sync_list; + unsigned int i, count; + + ctx->next_uid = 0; + + sync_list = array_get_modifyable(&ctx->sync_list, &count); + for (i = 0; i < count; i++) + sync_list[i].idx = 0; +} + static void mail_index_sync_end(struct mail_index_sync_ctx *ctx) { mail_index_unlock(ctx->index, ctx->lock_id); diff -r fb34cde02ac8 -r 98e3001ca527 src/lib-index/mail-index.h --- a/src/lib-index/mail-index.h Fri Apr 08 01:09:07 2005 +0300 +++ b/src/lib-index/mail-index.h Fri Apr 08 01:22:18 2005 +0300 @@ -225,6 +225,9 @@ struct mail_index_sync_rec *sync_rec); /* Returns 1 if there's more to sync, 0 if not. */ int mail_index_sync_have_more(struct mail_index_sync_ctx *ctx); +/* Reset syncing to initial state after mail_index_sync_begin(), so you can + go through all the sync records again with mail_index_sync_next(). */ +void mail_index_sync_reset(struct mail_index_sync_ctx *ctx); /* Commit synchronization by writing all changes to mail index file. */ int mail_index_sync_commit(struct mail_index_sync_ctx *ctx); /* Rollback synchronization - none of the changes listed by sync_next() are