diff --git a/VERSION b/VERSION index 524cb552..f7f5c7fe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.1 +1.2.0-pre1 diff --git a/src/pilerpurge.c b/src/pilerpurge.c index 64951729..ae75231f 100644 --- a/src/pilerpurge.c +++ b/src/pilerpurge.c @@ -244,7 +244,7 @@ int purge_messages_round1(struct session_data *sdata, struct __data *data, char snprintf(update_meta_sql, sizeof(update_meta_sql)-1, "%s", SQL_STMT_DELETE_FROM_META_TABLE); - snprintf(s, sizeof(s)-1, "SELECT `id`, `piler_id`, `size` FROM `%s` WHERE `deleted`=0 AND `retained` < %ld AND %s", SQL_METADATA_TABLE, sdata->now, attachment_condition); + snprintf(s, sizeof(s)-1, "SELECT `id`, `piler_id`, `size` FROM `%s` WHERE `deleted`=0 AND `retained` < %ld AND %s AND id NOT IN (SELECT id FROM `%s` WHERE `to` IN (SELECT email FROM `%s`)) AND id NOT IN (SELECT id FROM `%s` WHERE `from` IN (SELECT email FROM `%s`))", SQL_METADATA_TABLE, sdata->now, attachment_condition, SQL_RECIPIENT_TABLE, SQL_LEGAL_HOLD_TABLE, SQL_METADATA_TABLE, SQL_LEGAL_HOLD_TABLE); if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "purge sql: *%s*", s); diff --git a/util/db-mysql.sql b/util/db-mysql.sql index 23dbca3d..0267b9c5 100644 --- a/util/db-mysql.sql +++ b/util/db-mysql.sql @@ -55,8 +55,9 @@ create index metadata_idx4 on metadata(`bodydigest`); create index metadata_idx5 on metadata(`deleted`); create index metadata_idx6 on metadata(`arrived`); create index metadata_idx7 on metadata(`retained`); -create index metadata_idx8 on metadata(`fromdomain`); -create index metadata_idx9 on metadata(`sent`); +create index metadata_idx8 on metadata(`fromdomain`); +create index metadata_idx9 on metadata(`from`); +create index metadata_idx10 on metadata(`sent`); create table if not exists `rcpt` ( @@ -423,3 +424,9 @@ create table if not exists `autosearch` ( `query` varchar(512) not null ) Engine=InnoDB; + +create table if not exists `legal_hold` ( + email varchar(128) default not null +) Engine=InnoDB; + + diff --git a/util/db-upgrade-1.1.0-vs-1.2.0.sql b/util/db-upgrade-1.1.0-vs-1.2.0.sql index 8ef433d3..8e0a0fce 100644 --- a/util/db-upgrade-1.1.0-vs-1.2.0.sql +++ b/util/db-upgrade-1.1.0-vs-1.2.0.sql @@ -9,4 +9,5 @@ alter table retention_rule add column `body` varchar(128) default null; create unique index `entry` on archiving_rule (`domain`,`from`,`to`,`subject`,`body`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`); create unique index `entry` on retention_rule (`domain`,`from`,`to`,`subject`,`body`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`); +create index metadata_idx10 on metadata(`from`);