added a batch limit option to processing emails from a pop3 account

This commit is contained in:
SJ 2014-09-02 12:54:11 +02:00
parent 5551df3f9d
commit 977744d757
4 changed files with 19 additions and 5 deletions

View File

@ -12,9 +12,9 @@
#define PROGNAME "piler"
#define PILERGETD_PROGNAME "pilergetd"
#define VERSION "1.1.1"
#define VERSION "1.1.1-rc1"
#define BUILD 885
#define BUILD 886
#define HOSTID "mailarchiver"

View File

@ -269,6 +269,7 @@ struct import {
int status;
int total_messages;
int processed_messages;
int batch_processing_limit;
int import_job_id;
int remove_after_import;
int keep_eml;

View File

@ -484,7 +484,8 @@ int main(int argc, char **argv){
data.recursive_folder_names = 0;
data.quiet = 0;
import.import_job_id = import.total_messages = import.total_size = import.processed_messages = 0;
import.import_job_id = import.total_messages = import.total_size = import.processed_messages = import.batch_processing_limit = 0;
import.started = import.updated = import.finished = import.remove_after_import = 0;
import.extra_recipient = NULL;
@ -513,6 +514,7 @@ int main(int argc, char **argv){
{"folder", required_argument, 0, 'F' },
{"folder_imap", required_argument, 0, 'f' },
{"add-recipient",required_argument, 0, 'a' },
{"batch-limit", required_argument, 0, 'b' },
{"quiet", no_argument, 0, 'q' },
{"recursive", required_argument, 0, 'R' },
{"remove-after-import",no_argument, 0, 'r' },
@ -524,9 +526,9 @@ int main(int argc, char **argv){
int option_index = 0;
c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:GDRrqh?", long_options, &option_index);
c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:GDRrqh?", long_options, &option_index);
#else
c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:GDRrqh?");
c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:b:GDRrqh?");
#endif
if(c == -1) break;
@ -599,6 +601,10 @@ int main(int argc, char **argv){
data.import->remove_after_import = 1;
break;
case 'b' :
data.import->batch_processing_limit = atoi(optarg);
break;
case 'a' :
data.import->extra_recipient = optarg;
break;

View File

@ -209,6 +209,13 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data,
}
unlink(filename);
/* whether to quit after processing a batch of messages */
if(data->import->batch_processing_limit > 0 && data->import->processed_messages >= data->import->batch_processing_limit){
break;
}
}