diff src/indexer/indexer-client.c @ 13199:8dcb7c7f66d5

doveadm index: Added -n parameter to specify max number of recent msgs to perform indexing. The idea is that if a user hasn't opened the mailbox for a long time (or ever), there's not much point in wasting time on doing indexing.
author Timo Sirainen <tss@iki.fi>
date Wed, 10 Aug 2011 14:17:54 +0300
parents af8c5e56d098
children ad429a8311f4
line wrap: on
line diff
--- a/src/indexer/indexer-client.c	Wed Aug 10 13:46:31 2011 +0300
+++ b/src/indexer/indexer-client.c	Wed Aug 10 14:17:54 2011 +0300
@@ -67,9 +67,9 @@
 			     const char *const *args, const char **error_r)
 {
 	struct indexer_client_request *ctx = NULL;
-	unsigned int tag;
+	unsigned int tag, max_recent_msgs;
 
-	if (str_array_length(args) != 3) {
+	if (str_array_length(args) < 3) {
 		*error_r = "Wrong parameter count";
 		return -1;
 	}
@@ -77,6 +77,12 @@
 		*error_r = "Invalid tag";
 		return -1;
 	}
+	if (args[3] == NULL)
+		max_recent_msgs = 0;
+	else if (str_to_uint(args[3], &max_recent_msgs) < 0) {
+		*error_r = "Invalid max_recent_msgs";
+		return -1;
+	}
 
 	if (tag != 0) {
 		ctx = i_new(struct indexer_client_request, 1);
@@ -85,7 +91,8 @@
 		indexer_client_ref(client);
 	}
 
-	indexer_queue_append(client->queue, append, args[1], args[2], ctx);
+	indexer_queue_append(client->queue, append, args[1], args[2],
+			     max_recent_msgs, ctx);
 	o_stream_send_str(client->output, t_strdup_printf("%u\tOK\n", tag));
 	return 0;
 }