diff --git a/src/config.h b/src/config.h index fb278944..46175c87 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "0.1.23-master-branch" -#define BUILD 742 +#define BUILD 743 #define HOSTID "mailarchiver" diff --git a/src/message.c b/src/message.c index 8b2d1e1b..3d367934 100644 --- a/src/message.c +++ b/src/message.c @@ -423,6 +423,13 @@ CLOSE: } +void remove_stripped_attachments(struct _state *state){ + int i; + + for(i=1; i<=state->n_attachments; i++) unlink(state->attachments[i].internalname); +} + + int process_message(struct session_data *sdata, struct _state *state, struct __data *data, struct __config *cfg){ int i, rc; uint64 id=0; @@ -430,7 +437,7 @@ int process_message(struct session_data *sdata, struct _state *state, struct __d /* discard if existing message_id */ if(is_existing_message_id(sdata, state, data, cfg) == 1){ - for(i=1; i<=state->n_attachments; i++) unlink(state->attachments[i].internalname); + remove_stripped_attachments(state); if(strlen(state->b_journal_to) > 0){ id = get_metaid_by_messageid(sdata, state->message_id, cfg); diff --git a/src/piler.h b/src/piler.h index 8e3fcd93..83d03466 100644 --- a/src/piler.h +++ b/src/piler.h @@ -35,6 +35,7 @@ void digest_string(char *s, char *digest); int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg); +void remove_stripped_attachments(struct _state *state); int process_message(struct session_data *sdata, struct _state *state, struct __data *data, struct __config *cfg); int store_file(struct session_data *sdata, char *filename, int startpos, int len, struct __config *cfg); int remove_stored_message_files(struct session_data *sdata, struct _state *state, struct __config *cfg); diff --git a/src/session.c b/src/session.c index f9ee9847..4a146de7 100644 --- a/src/session.c +++ b/src/session.c @@ -217,6 +217,8 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ syslog(LOG_PRIORITY, "%s: discarding message by archiving policy: *%s*", sdata.ttmpfile, arule); inj = OK; counters.c_ignore++; + + remove_stripped_attachments(&sstate); } else { inj = process_message(&sdata, &sstate, data, cfg);