Skip to content

Commit fe9b73c

Browse files
author
Marius Cramer
committed
Merge branch 'master' into 'master'
Master See merge request !244
2 parents 26e265e + f562971 commit fe9b73c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,19 @@ public function onRunJob() {
198198

199199
/* remove archives */
200200
$mail_backup_dir = realpath($backup_dir.'/mail'.$domain_rec['domain_id']);
201-
$mail_backup_file = 'mail'.$rec['mailuser_id'].'_*';
201+
$mail_backup_file = 'mail'.$rec['mailuser_id'].'_';
202202
if(is_dir($mail_backup_dir)) {
203203
$dir_handle = opendir($mail_backup_dir.'/');
204204
while ($file = readdir($dir_handle)) {
205205
if(!is_dir($file)) {
206-
unlink ("$mail_backup_dir/"."$file");
206+
if(substr($file,0,strlen($mail_backup_file)) == $mail_backup_file) {
207+
unlink ($mail_backup_dir.'/'.$file);
208+
}
207209
}
208210
}
211+
if(count(glob($mail_backup_dir."/*", GLOB_NOSORT)) === 0) {
212+
rmdir($mail_backup_dir);
213+
}
209214
}
210215
/* remove backups from db */
211216
$sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND mailuser_id = ?";

0 commit comments

Comments
 (0)