fixing the binaries

Change-Id: I16d2a337434df289a0096669e55d0e7d80692a04
Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
SJ 2016-08-15 07:13:31 +02:00
parent f046ee38b5
commit eca0fd7280
6 changed files with 25 additions and 91 deletions

View File

@ -83,7 +83,7 @@
#define SQL_ARCHIVING_RULE_TABLE "archiving_rule"
#define SQL_RETENTION_RULE_TABLE "retention_rule"
#define SQL_FOLDER_RULE_TABLE "folder_rule"
#define SQL_FOLDER_USER_TABLE "folder_user"
#define SQL_FOLDER_TABLE "folder"
#define SQL_FOLDER_EMAIL_TABLE "folder_email"
#define SQL_COUNTER_TABLE "counter"
#define SQL_OPTION_TABLE "option"
@ -105,11 +105,9 @@
#define SQL_PREPARED_STMT_GET_ATTACHMENT_ID_BY_SIGNATURE "SELECT `id`, `piler_id`, `attachment_id` FROM `" SQL_ATTACHMENT_TABLE "` WHERE `sig`=? AND `size`=? AND `ptr`=0"
#define SQL_PREPARED_STMT_GET_ATTACHMENT_POINTER "SELECT `piler_id`, `attachment_id` FROM " SQL_ATTACHMENT_TABLE " WHERE id=?"
#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_USER_ID "SELECT `id` FROM " SQL_FOLDER_USER_TABLE " WHERE `name`=? AND `uid`=?"
#define SQL_PREPARED_STMT_GET_FOLDER_ID "SELECT `id` FROM " SQL_FOLDER_TABLE " WHERE `name`=? AND `uid`=? AND `parent_id`=?"
#define SQL_PREPARED_STMT_GET_FOLDER_UID_BY_EMAIL "SELECT `uid` FROM " SQL_FOLDER_EMAIL_TABLE " WHERE `email`=?"
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`name`, `parent_id`) VALUES(?,?)"
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_USER_TABLE "INSERT INTO `" SQL_FOLDER_USER_TABLE "` (`name`, `uid`) VALUES(?,?)"
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE "INSERT INTO `" SQL_FOLDER_TABLE "` (`uid`, `name`, `parent_id`) VALUES(?,?,?)"
#define SQL_PREPARED_STMT_INSERT_INTO_FOLDER_EMAIL_TABLE "INSERT INTO `" SQL_FOLDER_EMAIL_TABLE "` (`email`) VALUES(?)"
#define SQL_PREPARED_STMT_UPDATE_METADATA_REFERENCE "UPDATE " SQL_METADATA_TABLE " SET reference=? WHERE message_id=? AND 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"

View File

@ -59,14 +59,15 @@ void get_folder_uid_by_email(struct session_data *sdata, struct __data *data){
}
int get_folder_extra_id(struct session_data *sdata, struct __data *data, char *foldername){
int get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){
int id=ERR_FOLDER;
if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_USER_ID) == ERR) return id;
if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_ID) == ERR) return id;
p_bind_init(data);
data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = (char *)&(data->import->uid); data->type[data->pos] = TYPE_LONG; data->pos++;
data->sql[data->pos] = (char *)&parent_id; data->type[data->pos] = TYPE_LONG; data->pos++;
if(p_exec_query(sdata, data->stmt_get_folder_id, data) == OK){
@ -84,16 +85,17 @@ int get_folder_extra_id(struct session_data *sdata, struct __data *data, char *f
}
int add_new_folder_extra(struct session_data *sdata, struct __data *data, char *foldername){
int add_new_folder(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){
int id=ERR_FOLDER;
if(foldername == NULL) return id;
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_USER_TABLE) == ERR) return id;
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE) == ERR) return id;
p_bind_init(data);
data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = (char *)&(data->import->uid); data->type[data->pos] = TYPE_LONG; data->pos++;
data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = (char *)&parent_id; data->type[data->pos] = TYPE_LONG; data->pos++;
if(p_exec_query(sdata, data->stmt_insert_into_folder_table, data) == OK){
id = p_get_insert_id(data->stmt_insert_into_folder_table);

View File

@ -145,52 +145,6 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
}
int get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){
int id=ERR_FOLDER;
if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_ID) == ERR) return id;
p_bind_init(data);
data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = (char *)&parent_id; data->type[data->pos] = TYPE_LONG; data->pos++;
if(p_exec_query(sdata, data->stmt_get_folder_id, data) == OK){
p_bind_init(data);
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++;
p_store_results(data->stmt_get_folder_id, data);
p_fetch_results(data->stmt_get_folder_id);
p_free_results(data->stmt_get_folder_id);
}
close_prepared_statement(data->stmt_get_folder_id);
return id;
}
int add_new_folder(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){
int id=ERR_FOLDER;
if(foldername == NULL) return id;
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE) == ERR) return id;
p_bind_init(data);
data->sql[data->pos] = foldername; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = (char *)&parent_id; data->type[data->pos] = TYPE_LONG; data->pos++;
if(p_exec_query(sdata, data->stmt_insert_into_folder_table, data) == OK){
id = p_get_insert_id(data->stmt_insert_into_folder_table);
}
close_prepared_statement(data->stmt_insert_into_folder_table);
return id;
}
void update_import_job_stat(struct session_data *sdata, struct __data *data){
char buf[SMALLBUFSIZE];

View File

@ -58,10 +58,7 @@ int file_from_archive_to_network(char *filename, int sd, int tls_enable, struct
int get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id);
int add_new_folder(struct session_data *sdata, struct __data *data, char *foldername, int parent_id);
void get_folder_uid_by_email(struct session_data *sdata, struct __data *data);
int get_folder_extra_id(struct session_data *sdata, struct __data *data, char *foldername);
int add_new_folder_extra(struct session_data *sdata, struct __data *data, char *foldername);
int store_folder_id(struct session_data *sdata, struct __data *data, uint64 id);

View File

@ -280,11 +280,6 @@ int main(int argc, char **argv){
cfg = read_config(configfile);
if((data.recursive_folder_names == 1 || folder) && cfg.enable_folders == 0){
printf("please set enable_folders=1 in piler.conf to use the folder options\n");
return ERR;
}
/* make sure we don't discard messages without a valid Message-Id when importing manually */
cfg.archive_emails_not_having_message_id = 1;
@ -305,25 +300,21 @@ int main(int argc, char **argv){
memcached_init(&(data.memc), cfg.memcached_servers, 11211);
#endif
if(folder){
if(folder || data.recursive_folder_names == 1){
cfg.enable_folders = 1;
if(data.import->email){
get_folder_uid_by_email(&sdata, &data);
data.folder = get_folder_extra_id(&sdata, &data, folder);
if(data.folder == ERR_FOLDER){
data.folder = add_new_folder_extra(&sdata, &data, folder);
}
}
else {
data.folder = get_folder_id(&sdata, &data, folder, 0);
}
if(data.folder == ERR_FOLDER){
data.folder = add_new_folder(&sdata, &data, folder, 0);
}
if(folder){
data.folder = get_folder_id(&sdata, &data, folder, 0);
if(data.folder == ERR_FOLDER){
data.folder = add_new_folder(&sdata, &data, folder, 0);
}
if(data.folder == ERR_FOLDER){

View File

@ -271,28 +271,20 @@ create table if not exists `domain_user` (
create table if not exists `folder` (
`id` int not null auto_increment,
`folder_id` int not null auto_increment,
`parent_id` int default 0,
`uid` int default 0,
`name` char(64) not null,
unique(`parent_id`, `name`),
primary key (`id`)
unique(`uid`, `name`),
primary key (`folder_id`)
) Engine=InnoDB;
create table if not exists `folder_email` (
`uid` int unsigned not null auto_increment,
`email` char(128) not null unique,
key `folder_user_idx` (`uid`),
key `folder_user_idx2` (`email`)
) ENGINE=InnoDB;
create table if not exists `folder_user` (
`id` int unsigned not null auto_increment,
`uid` int unsigned not null,
`name` char(64) not null,
unique(uid, name),
key (`id`)
key `folder_email_idx` (`uid`),
key `folder_email_idx2` (`email`)
) ENGINE=InnoDB;