diff --git a/src/config.h b/src/config.h index c364b38c..3b962981 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "0.1.25-rc3" -#define BUILD 879 +#define BUILD 880 #define HOSTID "mailarchiver" diff --git a/src/defs.h b/src/defs.h index d85970c3..859b4f06 100644 --- a/src/defs.h +++ b/src/defs.h @@ -271,6 +271,7 @@ struct import { int import_job_id; int remove_after_import; int keep_eml; + long total_size; time_t started, updated, finished; }; diff --git a/src/imap.c b/src/imap.c index 13612688..d84ab9ae 100644 --- a/src/imap.c +++ b/src/imap.c @@ -163,8 +163,24 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda len = strlen(puf); if(nreads == 1){ - msglen = get_message_length_from_imap_answer(puf); - continue; + + if(strcasestr(puf, " FETCH ")){ + msglen = get_message_length_from_imap_answer(puf); + + if(msglen == 0){ + finished = 1; + break; + } + + continue; + } + + if(strcasestr(puf, " BYE")){ + printf("imap server sent BYE response: '%s'\n", puf); + close(fd); + unlink(filename); + return ERR; + } } if(len > 0){ @@ -199,7 +215,7 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda close(fd); - if(dryrun == 0) rc = import_message(filename, sdata, data, cfg); + if(dryrun == 0 && msglen > 10) rc = import_message(filename, sdata, data, cfg); else rc = OK; diff --git a/src/import.c b/src/import.c index c590e32b..e5948edc 100644 --- a/src/import.c +++ b/src/import.c @@ -67,6 +67,8 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename); sdata->tot_len = st.st_size; + + data->import->total_size += st.st_size; } diff --git a/src/pilerimport.c b/src/pilerimport.c index 905cd039..2f0d5b24 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -484,7 +484,7 @@ int main(int argc, char **argv){ data.recursive_folder_names = 0; data.quiet = 0; - import.import_job_id = import.total_messages = import.processed_messages = 0; + import.import_job_id = import.total_messages = import.total_size = import.processed_messages = 0; import.started = import.updated = import.finished = import.remove_after_import = 0; import.extra_recipient = NULL;