From 7085f3c225eb7c0ff7ece55576fe882ab04e9c6c Mon Sep 17 00:00:00 2001 From: SJ Date: Thu, 3 Jan 2013 15:14:07 +0100 Subject: [PATCH] fixed a bug (-A) in pilerexport --- src/pilerexport.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/pilerexport.c b/src/pilerexport.c index c7120025..fc45ed50 100644 --- a/src/pilerexport.c +++ b/src/pilerexport.c @@ -139,7 +139,7 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct MYSQL_RES *res; MYSQL_ROW row; FILE *f; - uint64 id; + uint64 id, n=0; char *digest=NULL, *bodydigest=NULL; char filename[SMALLBUFSIZE]; int rc=0; @@ -167,14 +167,17 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct rc = retrieve_email_from_archive(sdata, f, cfg); fclose(f); + n++; + snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename); make_digests(sdata, cfg); - if(strcmp(digest, sdata->digest) == 0 && strcmp(bodydigest, sdata->bodydigest) == 0) - printf("exported %s, verification: OK\n", filename); + if(strcmp(digest, sdata->digest) == 0 && strcmp(bodydigest, sdata->bodydigest) == 0){ + printf("exported: %10llu\r", n); fflush(stdout); + } else - printf("exported %s, verification: FAILED\n", filename); + printf("verification FAILED. %s\n", filename); } else printf("cannot open: %s\n", filename); @@ -190,6 +193,8 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct else rc = 1; } + printf("\n"); + return rc; } @@ -313,11 +318,15 @@ int main(int argc, char **argv){ (void) openlog("pilerexport", LOG_PID, LOG_MAIL); - snprintf(s, sizeof(s)-1, "SELECT DISTINCT `id`, `piler_id`, `digest`, `bodydigest` FROM %s WHERE ", SQL_MESSAGES_VIEW); rc = append_string_to_buffer(&query, s); + if(exportall == 1){ + rc += append_string_to_buffer(&query, "1=1"); + } + + if(from){ rc += append_string_to_buffer(&query, "`from` IN ("); rc += append_string_to_buffer(&query, from);