mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 07:51:58 +01:00
folder fixes
This commit is contained in:
parent
a28a44b88d
commit
1b693f3ba9
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define VERSION "0.1.24-master-branch"
|
#define VERSION "0.1.24-master-branch"
|
||||||
|
|
||||||
#define BUILD 817
|
#define BUILD 818
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
@ -116,6 +116,7 @@
|
|||||||
#define OK 0
|
#define OK 0
|
||||||
#define ERR 1
|
#define ERR 1
|
||||||
#define ERR_EXISTS 2
|
#define ERR_EXISTS 2
|
||||||
|
#define ERR_FOLDER -1
|
||||||
|
|
||||||
#define AVIR_OK 0
|
#define AVIR_OK 0
|
||||||
#define AVIR_VIRUS 1
|
#define AVIR_VIRUS 1
|
||||||
|
12
src/import.c
12
src/import.c
@ -72,6 +72,11 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
|
|||||||
state = parse_message(sdata, 1, data, cfg);
|
state = parse_message(sdata, 1, data, cfg);
|
||||||
post_parse(sdata, &state, cfg);
|
post_parse(sdata, &state, cfg);
|
||||||
|
|
||||||
|
if(sdata->hdr_len < 10){
|
||||||
|
printf("invalid message, hdr_len: %d\n", sdata->hdr_len);
|
||||||
|
return ERR;
|
||||||
|
}
|
||||||
|
|
||||||
if(sdata->sent <= 0 && sdata->delivered > 0) sdata->sent = sdata->delivered;
|
if(sdata->sent <= 0 && sdata->delivered > 0) sdata->sent = sdata->delivered;
|
||||||
|
|
||||||
if(sdata->sent > sdata->now) sdata->sent = sdata->now;
|
if(sdata->sent > sdata->now) sdata->sent = sdata->now;
|
||||||
@ -126,7 +131,7 @@ 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 get_folder_id(struct session_data *sdata, struct __data *data, char *foldername, int parent_id){
|
||||||
int id=-1;
|
int id=ERR_FOLDER;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -136,6 +141,7 @@ int get_folder_id(struct session_data *sdata, struct __data *data, char *foldern
|
|||||||
|
|
||||||
if(p_exec_query(sdata, data->stmt_get_folder_id, data) == OK){
|
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++;
|
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++;
|
||||||
|
|
||||||
p_store_results(sdata, data->stmt_get_folder_id, data);
|
p_store_results(sdata, data->stmt_get_folder_id, data);
|
||||||
@ -150,7 +156,9 @@ int get_folder_id(struct session_data *sdata, struct __data *data, char *foldern
|
|||||||
|
|
||||||
|
|
||||||
int 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 id=0;
|
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;
|
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_table), SQL_PREPARED_STMT_INSERT_INTO_FOLDER_TABLE) == ERR) return id;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ int import_mbox_from_dir(char *directory, struct session_data *sdata, struct __d
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
int rc=ERR, ret=OK, i=0;
|
int rc=ERR, ret=OK, i=0;
|
||||||
unsigned long folder;
|
int folder;
|
||||||
char fname[SMALLBUFSIZE];
|
char fname[SMALLBUFSIZE];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -132,10 +132,10 @@ int import_mbox_from_dir(char *directory, struct session_data *sdata, struct __d
|
|||||||
if(S_ISREG(st.st_mode)){
|
if(S_ISREG(st.st_mode)){
|
||||||
if(i == 0 && data->recursive_folder_names == 1){
|
if(i == 0 && data->recursive_folder_names == 1){
|
||||||
folder = get_folder_id(sdata, data, fname, data->folder);
|
folder = get_folder_id(sdata, data, fname, data->folder);
|
||||||
if(folder == -1){
|
if(folder == ERR_FOLDER){
|
||||||
folder = add_new_folder(sdata, data, fname, data->folder);
|
folder = add_new_folder(sdata, data, fname, data->folder);
|
||||||
|
|
||||||
if(folder == -1){
|
if(folder == ERR_FOLDER){
|
||||||
printf("error: cannot get/add folder '%s' to parent id: %d\n", fname, data->folder);
|
printf("error: cannot get/add folder '%s' to parent id: %d\n", fname, data->folder);
|
||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ int import_from_maildir(char *directory, struct session_data *sdata, struct __da
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
int rc=ERR, ret=OK, i=0;
|
int rc=ERR, ret=OK, i=0;
|
||||||
unsigned long folder;
|
int folder;
|
||||||
char *p, fname[SMALLBUFSIZE];
|
char *p, fname[SMALLBUFSIZE];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -208,10 +208,10 @@ int import_from_maildir(char *directory, struct session_data *sdata, struct __da
|
|||||||
}
|
}
|
||||||
|
|
||||||
folder = get_folder_id(sdata, data, p, data->folder);
|
folder = get_folder_id(sdata, data, p, data->folder);
|
||||||
if(folder == -1){
|
if(folder == ERR_FOLDER){
|
||||||
folder = add_new_folder(sdata, data, p, data->folder);
|
folder = add_new_folder(sdata, data, p, data->folder);
|
||||||
|
|
||||||
if(folder == -1){
|
if(folder == ERR_FOLDER){
|
||||||
printf("error: cannot get/add folder '%s' to parent id: %d\n", p, data->folder);
|
printf("error: cannot get/add folder '%s' to parent id: %d\n", p, data->folder);
|
||||||
return ERR;
|
return ERR;
|
||||||
}
|
}
|
||||||
@ -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 == -1){
|
if(data.folder == ERR_FOLDER){
|
||||||
data.folder = add_new_folder(&sdata, &data, folder, 0);
|
data.folder = add_new_folder(&sdata, &data, folder, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.folder == -1){
|
if(data.folder == ERR_FOLDER){
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user