diff --git a/server/lib/classes/cron.d/500-backup_mail.inc.php b/server/lib/classes/cron.d/500-backup_mail.inc.php index 028935065d452b32bd5e68d2cca2e4498d5f2d7a..acc324b8ffb64d11f04a5aa3b60f5c2ce71e90d7 100644 --- a/server/lib/classes/cron.d/500-backup_mail.inc.php +++ b/server/lib/classes/cron.d/500-backup_mail.inc.php @@ -203,9 +203,14 @@ class cronjob_backup_mail extends cronjob { $dir_handle = opendir($mail_backup_dir.'/'); while ($file = readdir($dir_handle)) { if(!is_dir($file)) { - unlink ("$mail_backup_dir/"."$file"); + if(substr($file,0,strlen($mail_backup_file)) == $mail_backup_file) { + unlink ($mail_backup_dir.'/'.$file); + } } } + if(count(glob($mail_backup_dir."/*", GLOB_NOSORT)) === 0) { + rmdir($mail_backup_dir); + } } /* remove backups from db */ $sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND mailuser_id = ?";