File tree Expand file tree Collapse file tree 2 files changed +15
-77
lines changed
server/lib/classes/cron.d Expand file tree Collapse file tree 2 files changed +15
-77
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ public function onRunJob() {
5555
5656 $ this ->purge_junk_thrash ();
5757 $ this ->purge_soft_deleted_maildir ();
58+ $ this ->purge_mdbox_removed ();
5859
5960 parent ::onRunJob ();
6061 }
@@ -136,6 +137,20 @@ private function purge_soft_deleted_maildir() {
136137 }
137138 }
138139
140+ // Remove messages with refcount=0 from mdbox files.
141+ private function purge_mdbox_removed () {
142+ global $ app , $ conf ;
143+
144+ $ sql = "SELECT email FROM mail_user WHERE maildir_format = 'mdbox' AND server_id = ? " ;
145+ $ records = $ app ->db ->queryAllRecords ($ sql , $ server_id );
146+
147+ if (is_array ($ records )) {
148+ foreach ($ records as $ rec ) {
149+ $ app ->system ->exec_safe ("su -c ? " , 'doveadm purge -u " ' . $ rec ["email " ] . '" ' );
150+ }
151+ }
152+ }
153+
139154 /* this function is optional if it contains no custom code */
140155 public function onAfterRun () {
141156 global $ app ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments