[evolution-data-server/gnome-3-4] Fix off-by-one in uidset handling for fetches



commit 3eab064e9e503567c0053fcf8e268d211451c79e
Author: David Woodhouse <David Woodhouse intel com>
Date:   Mon May 21 16:42:26 2012 +0100

    Fix off-by-one in uidset handling for fetches
    
    When we get to the end of the for() loop processing the uidset, the index
    variable is one *more* than the last item. That's how for() loops in C
    work.
    
    But when we break out of the middle because we are limiting the batch
    size, we were forgetting to do the same and we were storing the index
    of the last item that we'd already fetched.
    
    This was causing us to re-fetch the last message of one batch, as the
    first message of the next batch. Mostly harmless, but spotted and fixed
    as part of bug 667725.
    (cherry picked from commit 7dd91af4568d1247e32e33319a875c274d6c7ca5)

 camel/providers/imapx/camel-imapx-server.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 447e6d9..b69885b 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1370,7 +1370,7 @@ imapx_untagged (CamelIMAPXServer *is,
 						g_return_val_if_fail (data != NULL, FALSE);
 
 						min = data->last_index;
-						max = data->index;
+						max = data->index - 1;
 
 						/* array is sorted, so use a binary search */
 						do {
@@ -3462,7 +3462,7 @@ imapx_command_copy_messages_step_start (CamelIMAPXServer *is,
 		res = imapx_uidset_add (&data->uidset, ic, uid);
 		if (res == 1) {
 			camel_imapx_command_add (ic, " %f", data->dest);
-			data->index = i;
+			data->index = i + 1;
 			imapx_command_queue (is, ic);
 			return;
 		}
@@ -3753,7 +3753,7 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
 				res = imapx_uidset_add (&data->uidset, ic, r->uid);
 				if (res == 1) {
 					camel_imapx_command_add (ic, " (RFC822.SIZE RFC822.HEADER)");
-					data->index = i;
+					data->index = i + 1;
 					imapx_command_queue (is, ic);
 					return TRUE;
 				}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]