improved the folder importing feature

This commit is contained in:
SJ 2015-12-05 11:56:01 +01:00
parent f4152e1f64
commit 526295dae4
4 changed files with 16 additions and 6 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "1.2.0-master"
#define BUILD 929
#define BUILD 930
#define HOSTID "mailarchiver"

View File

@ -122,6 +122,13 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
if(messages <= 0) return OK;
if(data->recursive_folder_names == 1){
data->folder = get_folder_id(sdata, data, folder, 0, cfg);
if(data->folder == ERR_FOLDER) data->folder = add_new_folder(sdata, data, folder, 0, cfg);
}
data->import->total_messages += messages;
for(i=data->import->start_position; i<=messages; i++){
@ -461,10 +468,6 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
q++;
fldrlen = strtol(q, NULL, 10);
} else {
//if(*q == '"') q++;
//if(q[strlen(q)-1] == ' ') q[strlen(q)-1] = '\0';
//if(q[strlen(q)-1] == '"') q[strlen(q)-1] = '\0';
if(fldrlen) {
ruf = malloc(strlen(q) * 2 + 1);

View File

@ -132,6 +132,8 @@ int store_recipients(struct session_data *sdata, struct __data *data, char *to,
int store_folder_id(struct session_data *sdata, struct __data *data, uint64 id, struct __config *cfg){
int rc = ERR;
if(data->folder == ERR_FOLDER) return rc;
if(prepare_sql_statement(sdata, &(data->stmt_insert_into_folder_message_table), SQL_PREPARED_STMT_INSERT_FOLDER_MESSAGE, cfg) == ERR) return rc;
p_bind_init(data);

View File

@ -486,11 +486,11 @@ void usage(){
printf(" -f <imap folder> IMAP folder name to import\n");
printf(" -g <imap folder> Move email after import to this IMAP folder\n");
printf(" -F <folder> Piler folder name to assign to this import\n");
printf(" -R Assign IMAP folder names as Piler folder names\n");
printf(" -b <batch limit> Import only this many emails\n");
printf(" -s <start position> Start importing POP3 emails from this position\n");
printf(" -D Dry-run, do not import anything\n");
printf(" -o Only download emails for POP3/IMAP import\n");
printf(" -R Recursive piler folder names\n");
printf(" -r Remove imported emails\n");
printf(" -q Quiet mode\n");
@ -701,6 +701,11 @@ 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;