Skip to content

Commit e44f640

Browse files
committed
Integrate 600-purge_mailboxes.inc.php into 500-clean_mailboxes.inc.php
Both are supposed to run before midnight.
1 parent 7375ff1 commit e44f640

File tree

2 files changed

+15
-77
lines changed

2 files changed

+15
-77
lines changed

server/lib/classes/cron.d/500-clean_mailboxes.inc.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

server/lib/classes/cron.d/600-purge_mailboxes.inc.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)