From 5c02806a76eab60d97bcc129947d0921cb8ae9a6 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 25 Nov 2022 09:55:59 +0100 Subject: [PATCH] Handle the new logs/cache paths better --- .../v/0.0.0/app/libraries/RainLoop/Actions.php | 14 +++++++------- snappymail/v/0.0.0/setup.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index d9913e934..9e2c6c203 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -133,8 +133,9 @@ class Actions if ('syslog' === $sLogFileName) { $oDriver = new \MailSo\Log\Drivers\Syslog(); } else { - $sLogFileFullPath = \APP_PRIVATE_DATA . 'logs/' . $this->compileLogFileName($sLogFileName); - $oDriver = new \MailSo\Log\Drivers\File($sLogFileFullPath); + $sLogFileFullPath = \trim($this->oConfig->Get('logs', 'path', '')) ?: \APP_PRIVATE_DATA . 'logs'; + \is_dir($sLogFileFullPath) || \mkdir($sLogFileFullPath, 0700, true); + $oDriver = new \MailSo\Log\Drivers\File($sLogFileFullPath . '/' . $this->compileLogFileName($sLogFileName)); } $this->oLogger->append($oDriver ->SetTimeZone($this->oConfig->Get('logs', 'time_zone', 'UTC')) @@ -509,6 +510,8 @@ class Actions switch (true) { default: case $bForceFile: + $sCacheDir = \trim($this->oConfig->Get('cache', 'path', '')) ?: APP_PRIVATE_DATA . 'cache'; + \is_dir($sCacheDir) || \mkdir($sCacheDir, 0700, true); $oDriver = new \MailSo\Cache\Drivers\File( \trim($this->oConfig->Get('cache', 'path', APP_PRIVATE_DATA . 'cache')), $sKey @@ -569,13 +572,10 @@ class Actions if ($this->oConfig->Get('logs', 'auth_logging', false)) { // $this->oLoggerAuth->SetLevel(\LOG_WARNING); - $sAuthLogFileFullPath = \trim($this->oConfig->Get('logs', 'path', \APP_PRIVATE_DATA . 'logs')) + $sAuthLogFileFullPath = (\trim($this->oConfig->Get('logs', 'path', '') ?: \APP_PRIVATE_DATA . 'logs')) . '/' . $this->compileLogFileName($this->oConfig->Get('logs', 'auth_logging_filename', '')); $sLogFileDir = \dirname($sAuthLogFileFullPath); - if (!\is_dir($sLogFileDir)) { - \mkdir($sLogFileDir, 0755, true); - } - + \is_dir($sLogFileDir) || \mkdir($sLogFileDir, 0755, true); $this->oLoggerAuth->append( (new \MailSo\Log\Drivers\File($sAuthLogFileFullPath)) ->DisableTimePrefix() diff --git a/snappymail/v/0.0.0/setup.php b/snappymail/v/0.0.0/setup.php index 068fdfa2f..c74f4ee9b 100644 --- a/snappymail/v/0.0.0/setup.php +++ b/snappymail/v/0.0.0/setup.php @@ -135,7 +135,7 @@ if (defined('APP_VERSION')) clearstatcache(); } - foreach (array('logs', 'cache', 'configs', 'domains', 'plugins', 'storage') as $sName) + foreach (array('configs', 'domains', 'plugins', 'storage') as $sName) { if (!is_dir(APP_PRIVATE_DATA.$sName)) {