mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 19:40:11 +01:00
Improved reference handling of imported messages
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
e3973144b4
commit
06c929ce7e
@ -108,6 +108,7 @@
|
|||||||
#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=''"
|
#define SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE "UPDATE " SQL_METADATA_TABLE " SET reference=? WHERE message_id=? AND reference=''"
|
||||||
|
#define SQL_PREPARED_STMT_GET_METADATA_REFERENCE "SELECT COUNT(*) AS count FROM " SQL_METADATA_TABLE " WHERE reference=?"
|
||||||
#define SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS "SELECT id, type, username, password, server FROM " SQL_IMPORT_TABLE " WHERE started=0 ORDER BY id LIMIT 0,1"
|
#define SQL_PREPARED_STMT_GET_GUI_IMPORT_JOBS "SELECT id, type, username, password, server FROM " SQL_IMPORT_TABLE " WHERE started=0 ORDER BY id LIMIT 0,1"
|
||||||
#define SQL_PREPARED_STMT_INSERT_FOLDER_MESSAGE "INSERT INTO " SQL_FOLDER_MESSAGE_TABLE " (`folder_id`, `id`) VALUES(?,?)"
|
#define SQL_PREPARED_STMT_INSERT_FOLDER_MESSAGE "INSERT INTO " SQL_FOLDER_MESSAGE_TABLE " (`folder_id`, `id`) VALUES(?,?)"
|
||||||
#define SQL_PREPARED_STMT_UPDATE_IMPORT_TABLE "UPDATE " SQL_IMPORT_TABLE " SET started=?, status=?, imported=? WHERE id=?"
|
#define SQL_PREPARED_STMT_UPDATE_IMPORT_TABLE "UPDATE " SQL_IMPORT_TABLE " SET started=?, status=?, imported=? WHERE id=?"
|
||||||
|
@ -213,6 +213,33 @@ int store_meta_data(struct session_data *sdata, struct parser_state *state, stru
|
|||||||
digest_string(state->reference, &ref[0]);
|
digest_string(state->reference, &ref[0]);
|
||||||
update_metadata_reference(sdata, state, &ref[0], cfg);
|
update_metadata_reference(sdata, state, &ref[0], cfg);
|
||||||
}
|
}
|
||||||
|
else if(state->reference[0] == 0){
|
||||||
|
// during import, the order of messages is often random
|
||||||
|
// check if this is a message which is already referenced
|
||||||
|
uint64 count=0;
|
||||||
|
|
||||||
|
digest_string(state->message_id, &ref[0]);
|
||||||
|
if(prepare_sql_statement(sdata, &sql, SQL_PREPARED_STMT_GET_METADATA_REFERENCE) != ERR){
|
||||||
|
p_bind_init(&sql);
|
||||||
|
|
||||||
|
sql.sql[sql.pos] = &ref[0]; sql.type[sql.pos] = TYPE_STRING; sql.pos++;
|
||||||
|
|
||||||
|
if(p_exec_stmt(sdata, &sql) == OK){
|
||||||
|
p_bind_init(&sql);
|
||||||
|
|
||||||
|
sql.sql[sql.pos] = (char *)&count; sql.type[sql.pos] = TYPE_LONGLONG; sql.len[sql.pos] = sizeof(uint64); sql.pos++;
|
||||||
|
p_store_results(&sql);
|
||||||
|
p_fetch_results(&sql);
|
||||||
|
p_free_results(&sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close_prepared_statement(&sql);
|
||||||
|
|
||||||
|
// no reference yet
|
||||||
|
if(count <= 0)
|
||||||
|
ref[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(prepare_sql_statement(sdata, &sql, SQL_PREPARED_STMT_INSERT_INTO_META_TABLE) == ERR) return ERR;
|
if(prepare_sql_statement(sdata, &sql, SQL_PREPARED_STMT_INSERT_INTO_META_TABLE) == ERR) return ERR;
|
||||||
|
Loading…
Reference in New Issue
Block a user