From 8ecbd3ecf2ba0c2382cadfb5b24412f82bf94e4c Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 19 Feb 2016 21:22:53 +0100 Subject: [PATCH] export only not deleted emails --- src/pilerexport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pilerexport.c b/src/pilerexport.c index f747e76b..9cb53b07 100644 --- a/src/pilerexport.c +++ b/src/pilerexport.c @@ -230,20 +230,22 @@ void export_emails_matching_id_list(struct session_data *sdata, struct session_d int build_query_from_args(char *from, char *to, char *fromdomain, char *todomain, int minsize, int maxsize, unsigned long startdate, unsigned long stopdate){ - int where_condition=0; + int where_condition=1; char s[SMALLBUFSIZE]; if(exportall == 1){ - rc = append_string_to_buffer(&query, "SELECT `id`, `piler_id`, `digest`, `bodydigest` FROM "); + rc = append_string_to_buffer(&query, "SELECT `id`, `piler_id`, `digest`, `bodydigest` FROM WHERE deleted=0"); rc += append_string_to_buffer(&query, SQL_METADATA_TABLE); return rc; } - snprintf(s, sizeof(s)-1, "SELECT DISTINCT `id`, `piler_id`, `digest`, `bodydigest` FROM %s WHERE ", SQL_MESSAGES_VIEW); + snprintf(s, sizeof(s)-1, "SELECT DISTINCT `id`, `piler_id`, `digest`, `bodydigest` FROM %s WHERE deleted=0 ", SQL_MESSAGES_VIEW); rc = append_string_to_buffer(&query, s); if(from){ + if(where_condition) rc = append_string_to_buffer(&query, " AND "); + rc += append_string_to_buffer(&query, "`from` IN ("); rc += append_string_to_buffer(&query, from); rc += append_string_to_buffer(&query, ")");