folder handling fix

This commit is contained in:
SJ 2013-06-19 13:36:58 +02:00
parent 7dd81479a1
commit 4fac30507d
3 changed files with 8 additions and 8 deletions

View File

@ -125,8 +125,8 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
} }
unsigned long get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){ int get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){
unsigned long id=0; int id=-1;
if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_ID) == ERR) return id; if(prepare_sql_statement(sdata, &(data->stmt_get_folder_id), SQL_PREPARED_STMT_GET_FOLDER_ID) == ERR) return id;
@ -149,8 +149,8 @@ unsigned long get_folder_id(struct session_data *sdata, struct __data *data, cha
} }
unsigned long add_new_folder(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){
unsigned long id=0; int id=0;
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_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;

View File

@ -55,8 +55,8 @@ int retrieve_email_from_archive(struct session_data *sdata, struct __data *data,
int file_from_archive_to_network(char *filename, int sd, int tls_enable, struct __data *data, struct __config *cfg); int file_from_archive_to_network(char *filename, int sd, int tls_enable, struct __data *data, struct __config *cfg);
int import_message(char *filename, struct session_data *sdata, struct __data *data, struct __config *cfg); int import_message(char *filename, struct session_data *sdata, struct __data *data, struct __config *cfg);
unsigned long get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id); int get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id);
unsigned long add_new_folder(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);
int store_index_data(struct session_data *sdata, struct _state *state, struct __data *data, uint64 id, struct __config *cfg); int store_index_data(struct session_data *sdata, struct _state *state, struct __data *data, uint64 id, struct __config *cfg);

View File

@ -543,11 +543,11 @@ int main(int argc, char **argv){
if(folder){ if(folder){
data.folder = get_folder_id(&sdata, &data, folder, 0); data.folder = get_folder_id(&sdata, &data, folder, 0);
if(data.folder == 0){ if(data.folder == -1){
data.folder = add_new_folder(&sdata, &data, folder, 0); data.folder = add_new_folder(&sdata, &data, folder, 0);
} }
if(data.folder == 0){ if(data.folder == -1){
printf("error: cannot get/add folder '%s'\n", folder); printf("error: cannot get/add folder '%s'\n", folder);
close_database(&sdata); close_database(&sdata);
return 0; return 0;