mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:41:59 +01:00
pilerexport dryrun prints the total number of attachments as well
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
7b47ce3ca2
commit
f268396233
@ -170,7 +170,7 @@ uint64 run_query(struct session_data *sdata, struct session_data *sdata2, char *
|
|||||||
|
|
||||||
if(!where_condition) return id;
|
if(!where_condition) return id;
|
||||||
|
|
||||||
snprintf(s, sizeof(s)-1, "SELECT `id`, `piler_id`, `digest`, `bodydigest` FROM %s WHERE id IN (", SQL_METADATA_TABLE);
|
snprintf(s, sizeof(s)-1, "SELECT `id`, `piler_id`, `digest`, `bodydigest`, `attachments` FROM %s WHERE id IN (", SQL_METADATA_TABLE);
|
||||||
rc += append_string_to_buffer(&query, s);
|
rc += append_string_to_buffer(&query, s);
|
||||||
|
|
||||||
snprintf(s, sizeof(s)-1, "SELECT id FROM %s WHERE %s AND id > %llu ORDER BY id ASC LIMIT 0,%d", index_list, where_condition, last_id, max_matches);
|
snprintf(s, sizeof(s)-1, "SELECT id FROM %s WHERE %s AND id > %llu ORDER BY id ASC LIMIT 0,%d", index_list, where_condition, last_id, max_matches);
|
||||||
@ -244,13 +244,13 @@ int build_query_from_args(char *from, char *to, char *fromdomain, char *todomain
|
|||||||
int rc=0;
|
int rc=0;
|
||||||
|
|
||||||
if(exportall == 1){
|
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`, `attachments` FROM ");
|
||||||
rc += append_string_to_buffer(&query, SQL_METADATA_TABLE);
|
rc += append_string_to_buffer(&query, SQL_METADATA_TABLE);
|
||||||
rc += append_string_to_buffer(&query, " WHERE deleted=0 ");
|
rc += append_string_to_buffer(&query, " WHERE deleted=0 ");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(s, sizeof(s)-1, "SELECT DISTINCT `id`, `piler_id`, `digest`, `bodydigest` FROM %s WHERE deleted=0 ", SQL_MESSAGES_VIEW);
|
snprintf(s, sizeof(s)-1, "SELECT DISTINCT `id`, `piler_id`, `digest`, `bodydigest`, `attachments` FROM %s WHERE deleted=0 ", SQL_MESSAGES_VIEW);
|
||||||
|
|
||||||
rc = append_string_to_buffer(&query, s);
|
rc = append_string_to_buffer(&query, s);
|
||||||
|
|
||||||
@ -356,7 +356,8 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct
|
|||||||
char digest[SMALLBUFSIZE], bodydigest[SMALLBUFSIZE];
|
char digest[SMALLBUFSIZE], bodydigest[SMALLBUFSIZE];
|
||||||
char filename[SMALLBUFSIZE];
|
char filename[SMALLBUFSIZE];
|
||||||
struct sql sql;
|
struct sql sql;
|
||||||
int errorp, rc=0;
|
int errorp, rc=0, attachments;
|
||||||
|
unsigned long total_attachments=0;
|
||||||
|
|
||||||
if(prepare_sql_statement(sdata, &sql, s) == ERR) return ERR;
|
if(prepare_sql_statement(sdata, &sql, s) == ERR) return ERR;
|
||||||
|
|
||||||
@ -373,6 +374,7 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct
|
|||||||
sql.sql[sql.pos] = sdata->ttmpfile; sql.type[sql.pos] = TYPE_STRING; sql.len[sql.pos] = RND_STR_LEN; sql.pos++;
|
sql.sql[sql.pos] = sdata->ttmpfile; sql.type[sql.pos] = TYPE_STRING; sql.len[sql.pos] = RND_STR_LEN; sql.pos++;
|
||||||
sql.sql[sql.pos] = &digest[0]; sql.type[sql.pos] = TYPE_STRING; sql.len[sql.pos] = sizeof(digest)-2; sql.pos++;
|
sql.sql[sql.pos] = &digest[0]; sql.type[sql.pos] = TYPE_STRING; sql.len[sql.pos] = sizeof(digest)-2; sql.pos++;
|
||||||
sql.sql[sql.pos] = &bodydigest[0]; sql.type[sql.pos] = TYPE_STRING; sql.len[sql.pos] = sizeof(bodydigest)-2; sql.pos++;
|
sql.sql[sql.pos] = &bodydigest[0]; sql.type[sql.pos] = TYPE_STRING; sql.len[sql.pos] = sizeof(bodydigest)-2; sql.pos++;
|
||||||
|
sql.sql[sql.pos] = (char *)&attachments; sql.type[sql.pos] = TYPE_LONG; sql.len[sql.pos] = sizeof(int); sql.pos++;
|
||||||
|
|
||||||
p_store_results(&sql);
|
p_store_results(&sql);
|
||||||
|
|
||||||
@ -445,6 +447,7 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct
|
|||||||
else printf("cannot open: %s\n", filename);
|
else printf("cannot open: %s\n", filename);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
total_attachments += attachments;
|
||||||
printf("id:%llu\n", id);
|
printf("id:%llu\n", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,6 +460,10 @@ int export_emails_matching_to_query(struct session_data *sdata, char *s, struct
|
|||||||
ENDE:
|
ENDE:
|
||||||
close_prepared_statement(&sql);
|
close_prepared_statement(&sql);
|
||||||
|
|
||||||
|
if(dryrun){
|
||||||
|
printf("attachments: %lu\n", total_attachments);
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user