From fe3d5f97447f0ac81b459475e80f36ff4a3c3e13 Mon Sep 17 00:00:00 2001 From: SJ Date: Sun, 24 Jan 2016 15:23:47 +0100 Subject: [PATCH] folder reindex fix --- src/config.h | 2 +- src/reindex.c | 9 ++++++++- src/rules.c | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config.h b/src/config.h index a2001ac0..9483c641 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "1.2.0-master" -#define BUILD 935 +#define BUILD 936 #define HOSTID "mailarchiver" diff --git a/src/reindex.c b/src/reindex.c index c3e19c58..4c720801 100644 --- a/src/reindex.c +++ b/src/reindex.c @@ -82,7 +82,11 @@ uint64 retrieve_email_by_metadata_id(struct session_data *sdata, struct __data * delta = to_id - from_id; - snprintf(s, sizeof(s)-1, "SELECT `id`, `piler_id`, `arrived`, `sent` FROM %s WHERE (id BETWEEN %llu AND %llu) AND `deleted`=0", SQL_METADATA_TABLE, from_id, to_id); + if(cfg->enable_folders == 1) + snprintf(s, sizeof(s)-1, "SELECT m.`id`, `piler_id`, `arrived`, `sent`, f.folder_id FROM %s m, %s f WHERE m.id=f.id AND (m.id BETWEEN %llu AND %llu) AND `deleted`=0", SQL_METADATA_TABLE, SQL_FOLDER_MESSAGE_TABLE, from_id, to_id); + else + snprintf(s, sizeof(s)-1, "SELECT `id`, `piler_id`, `arrived`, `sent` FROM %s WHERE (id BETWEEN %llu AND %llu) AND `deleted`=0", SQL_METADATA_TABLE, from_id, to_id); + if(prepare_sql_statement(sdata, &(data->stmt_generic), s, cfg) == ERR) return reindexed; @@ -96,6 +100,9 @@ uint64 retrieve_email_by_metadata_id(struct session_data *sdata, struct __data * data->sql[data->pos] = sdata->ttmpfile; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = RND_STR_LEN+2; data->pos++; data->sql[data->pos] = (char *)&(sdata->now); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++; data->sql[data->pos] = (char *)&(sdata->sent); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++; + if(cfg->enable_folders == 1){ + data->sql[data->pos] = (char *)&(data->folder); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++; + } p_store_results(sdata, data->stmt_generic, data); diff --git a/src/rules.c b/src/rules.c index 7339e058..d77ffd44 100644 --- a/src/rules.c +++ b/src/rules.c @@ -322,6 +322,8 @@ int get_folder_id_by_rule(struct __data *data, struct parser_state *state, int s struct node *q; int ismatch; + if(cfg->enable_folders == 0) return 0; + q = data->folder_rules[0]; while(q != NULL){