remove message files if it's a duplicate according to message-id

This commit is contained in:
SJ 2012-05-29 14:08:56 +02:00
parent 154780c4a7
commit cbd986a29c
3 changed files with 32 additions and 1 deletions

View File

@ -416,7 +416,12 @@ int process_message(struct session_data *sdata, struct _state *state, struct __d
rc = store_meta_data(sdata, state, cfg);
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: stored metadata, rc=%d", sdata->ttmpfile, rc);
if(rc == ERR_EXISTS) return ERR_EXISTS;
if(rc == ERR_EXISTS){
remove_stored_message_files(sdata, state, cfg);
return ERR_EXISTS;
}
return OK;
}

View File

@ -37,6 +37,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg);
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);
int store_attachments(struct session_data *sdata, struct _state *state, struct __config *cfg);
int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr, struct __config *cfg);

View File

@ -173,3 +173,28 @@ ENDE:
}
int remove_stored_message_files(struct session_data *sdata, struct _state *state, struct __config *cfg){
int i;
char s[SMALLBUFSIZE];
if(state->n_attachments > 0){
for(i=1; i<=state->n_attachments; i++){
snprintf(s, sizeof(s)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, sdata->ttmpfile[RND_STR_LEN-6], sdata->ttmpfile[RND_STR_LEN-5], sdata->ttmpfile[RND_STR_LEN-4], sdata->ttmpfile[RND_STR_LEN-3], sdata->ttmpfile[RND_STR_LEN-2], sdata->ttmpfile[RND_STR_LEN-1], sdata->ttmpfile, i);
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: unlinking %s", sdata->ttmpfile, s);
unlink(s);
}
}
snprintf(s, sizeof(s)-1, "%s/%c%c/%c%c/%c%c/%s.m", cfg->queuedir, sdata->ttmpfile[RND_STR_LEN-6], sdata->ttmpfile[RND_STR_LEN-5], sdata->ttmpfile[RND_STR_LEN-4], sdata->ttmpfile[RND_STR_LEN-3], sdata->ttmpfile[RND_STR_LEN-2], sdata->ttmpfile[RND_STR_LEN-1], sdata->ttmpfile);
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: unlinking %s", sdata->ttmpfile, s);
unlink(s);
return 0;
}