mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 19:20:12 +01:00
added a fix to find the first message of a thread
This commit is contained in:
parent
266003afb6
commit
15f18eb939
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#define VERSION "0.1.23-master-branch"
|
#define VERSION "0.1.23-master-branch"
|
||||||
|
|
||||||
#define BUILD 770
|
#define BUILD 774
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
@ -97,6 +97,7 @@
|
|||||||
#define SQL_PREPARED_STMT_QUERY_ATTACHMENT "SELECT `attachment_id`, `ptr` FROM " SQL_ATTACHMENT_TABLE " WHERE piler_id=? ORDER BY attachment_id ASC"
|
#define SQL_PREPARED_STMT_QUERY_ATTACHMENT "SELECT `attachment_id`, `ptr` FROM " SQL_ATTACHMENT_TABLE " WHERE piler_id=? ORDER BY attachment_id ASC"
|
||||||
#define SQL_PREPARED_STMT_GET_FOLDER_ID "SELECT `id` FROM " SQL_FOLDER_TABLE " WHERE `name`=? AND `parent_id`=?"
|
#define SQL_PREPARED_STMT_GET_FOLDER_ID "SELECT `id` FROM " SQL_FOLDER_TABLE " WHERE `name`=? AND `parent_id`=?"
|
||||||
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`name`, `parent_id`) VALUES(?,?)"
|
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`name`, `parent_id`) VALUES(?,?)"
|
||||||
|
#define SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE "UPDATE " SQL_METADATA_TABLE " SET reference=? WHERE message_id=? AND reference=''"
|
||||||
|
|
||||||
|
|
||||||
/* Error codes */
|
/* Error codes */
|
||||||
|
@ -256,7 +256,8 @@ struct __data {
|
|||||||
MYSQL_STMT *stmt_get_attachment_pointer;
|
MYSQL_STMT *stmt_get_attachment_pointer;
|
||||||
MYSQL_STMT *stmt_query_attachment;
|
MYSQL_STMT *stmt_query_attachment;
|
||||||
MYSQL_STMT *stmt_get_folder_id;
|
MYSQL_STMT *stmt_get_folder_id;
|
||||||
MYSQL_STMT *stmt_insert_into_folder_table;
|
MYSQL_STMT *stmt_insert_into_folder_table;
|
||||||
|
MYSQL_STMT *stmt_update_metadata_reference;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_TRE
|
#ifdef HAVE_TRE
|
||||||
|
@ -234,6 +234,38 @@ CLOSE:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int update_metadata_reference(struct session_data *sdata, struct _state *state, struct __data *data, char *ref, struct __config *cfg){
|
||||||
|
int rc, ret = ERR;
|
||||||
|
MYSQL_BIND bind[2];
|
||||||
|
unsigned long len[2];
|
||||||
|
|
||||||
|
memset(bind, 0, sizeof(bind));
|
||||||
|
|
||||||
|
bind[0].buffer_type = MYSQL_TYPE_STRING;
|
||||||
|
bind[0].buffer = ref;
|
||||||
|
bind[0].is_null = 0;
|
||||||
|
len[0] = strlen(ref); bind[0].length = &len[0];
|
||||||
|
|
||||||
|
bind[1].buffer_type = MYSQL_TYPE_STRING;
|
||||||
|
bind[1].buffer = state->message_id;
|
||||||
|
bind[1].is_null = 0;
|
||||||
|
len[1] = strlen(state->message_id); bind[1].length = &len[1];
|
||||||
|
|
||||||
|
if(mysql_stmt_bind_param(data->stmt_update_metadata_reference, bind)){
|
||||||
|
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(data->stmt_update_metadata_reference));
|
||||||
|
goto CLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = mysql_stmt_execute(data->stmt_update_metadata_reference);
|
||||||
|
if(rc == 0) ret = OK;
|
||||||
|
|
||||||
|
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: updated meta reference for '%s', rc=%d", sdata->ttmpfile, state->message_id, rc);
|
||||||
|
|
||||||
|
CLOSE:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int store_meta_data(struct session_data *sdata, struct _state *state, struct __data *data, struct __config *cfg){
|
int store_meta_data(struct session_data *sdata, struct _state *state, struct __data *data, struct __config *cfg){
|
||||||
int rc, ret=ERR;
|
int rc, ret=ERR;
|
||||||
char *subj, *p, s[MAXBUFSIZE], s2[SMALLBUFSIZE], vcode[2*DIGEST_LENGTH+1], ref[2*DIGEST_LENGTH+1];
|
char *subj, *p, s[MAXBUFSIZE], s2[SMALLBUFSIZE], vcode[2*DIGEST_LENGTH+1], ref[2*DIGEST_LENGTH+1];
|
||||||
@ -252,7 +284,10 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __d
|
|||||||
digest_string(s, &vcode[0]);
|
digest_string(s, &vcode[0]);
|
||||||
|
|
||||||
memset(ref, 0, sizeof(ref));
|
memset(ref, 0, sizeof(ref));
|
||||||
if(strlen(state->reference) > 10) digest_string(state->reference, &ref[0]);
|
if(strlen(state->reference) > 10){
|
||||||
|
digest_string(state->reference, &ref[0]);
|
||||||
|
update_metadata_reference(sdata, state, data, &ref[0], cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(prepare_a_mysql_statement(sdata, &(data->stmt_insert_into_meta_table), SQL_PREPARED_STMT_INSERT_INTO_META_TABLE) == ERR) return ERR;
|
if(prepare_a_mysql_statement(sdata, &(data->stmt_insert_into_meta_table), SQL_PREPARED_STMT_INSERT_INTO_META_TABLE) == ERR) return ERR;
|
||||||
|
@ -41,9 +41,11 @@ int create_prepared_statements(struct session_data *sdata, struct __data *data){
|
|||||||
|
|
||||||
data->stmt_get_meta_id_by_message_id = NULL;
|
data->stmt_get_meta_id_by_message_id = NULL;
|
||||||
data->stmt_insert_into_rcpt_table = NULL;
|
data->stmt_insert_into_rcpt_table = NULL;
|
||||||
|
data->stmt_update_metadata_reference = NULL;
|
||||||
|
|
||||||
if(prepare_a_mysql_statement(sdata, &(data->stmt_get_meta_id_by_message_id), SQL_PREPARED_STMT_GET_META_ID_BY_MESSAGE_ID) == ERR) rc = ERR;
|
if(prepare_a_mysql_statement(sdata, &(data->stmt_get_meta_id_by_message_id), SQL_PREPARED_STMT_GET_META_ID_BY_MESSAGE_ID) == ERR) rc = ERR;
|
||||||
if(prepare_a_mysql_statement(sdata, &(data->stmt_insert_into_rcpt_table), SQL_PREPARED_STMT_INSERT_INTO_RCPT_TABLE) == ERR) rc = ERR;
|
if(prepare_a_mysql_statement(sdata, &(data->stmt_insert_into_rcpt_table), SQL_PREPARED_STMT_INSERT_INTO_RCPT_TABLE) == ERR) rc = ERR;
|
||||||
|
if(prepare_a_mysql_statement(sdata, &(data->stmt_update_metadata_reference), SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE) == ERR) rc = ERR;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -52,5 +54,6 @@ int create_prepared_statements(struct session_data *sdata, struct __data *data){
|
|||||||
void close_prepared_statements(struct __data *data){
|
void close_prepared_statements(struct __data *data){
|
||||||
if(data->stmt_get_meta_id_by_message_id) mysql_stmt_close(data->stmt_get_meta_id_by_message_id);
|
if(data->stmt_get_meta_id_by_message_id) mysql_stmt_close(data->stmt_get_meta_id_by_message_id);
|
||||||
if(data->stmt_insert_into_rcpt_table) mysql_stmt_close(data->stmt_insert_into_rcpt_table);
|
if(data->stmt_insert_into_rcpt_table) mysql_stmt_close(data->stmt_insert_into_rcpt_table);
|
||||||
|
if(data->stmt_update_metadata_reference) mysql_stmt_close(data->stmt_update_metadata_reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user