From 3015ec283d80e01158cd90b7ea02e24d080a06a7 Mon Sep 17 00:00:00 2001
From: Jesse Norell <jesse@kci.net>
Date: Thu, 2 Jul 2020 13:37:27 -0600
Subject: [PATCH] add quota recalc to mailbox cleanup

---
 server/lib/classes/cron.d/500-clean_mailboxes.inc.php | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/server/lib/classes/cron.d/500-clean_mailboxes.inc.php b/server/lib/classes/cron.d/500-clean_mailboxes.inc.php
index 8617d0d76d..7e8c82da64 100755
--- a/server/lib/classes/cron.d/500-clean_mailboxes.inc.php
+++ b/server/lib/classes/cron.d/500-clean_mailboxes.inc.php
@@ -57,6 +57,7 @@ class cronjob_clean_mailboxes extends cronjob {
 		$junk_names=array('Junk', 'Junk Email', 'SPAM', 'INBOX.SPAM');
 
 		$purge_cmd = 'doveadm expunge -u ? mailbox ? sentbefore ';
+		$recalc_cmd = 'doveadm quota recalc -u ?';
 
 		$server_id = intval($conf['server_id']);
 		$records = $app->db->queryAllRecords("SELECT email, maildir, purge_trash_days, purge_junk_days FROM mail_user WHERE maildir_format = 'maildir' AND disableimap = 'n' AND server_id = ? AND (purge_trash_days > 0 OR purge_junk_days > 0)", $server_id);
@@ -77,6 +78,7 @@ class cronjob_clean_mailboxes extends cronjob {
 						}
 					}
 				}
+				$app->system->exec_safe($recalc_cmd, $email['email']);
 			}
 		}
 
-- 
GitLab