Handle the new logs/cache paths better

This commit is contained in:
the-djmaze 2022-11-25 09:55:59 +01:00
parent dee6f6af7e
commit 5c02806a76
2 changed files with 8 additions and 8 deletions

View file

@ -133,8 +133,9 @@ class Actions
if ('syslog' === $sLogFileName) { if ('syslog' === $sLogFileName) {
$oDriver = new \MailSo\Log\Drivers\Syslog(); $oDriver = new \MailSo\Log\Drivers\Syslog();
} else { } else {
$sLogFileFullPath = \APP_PRIVATE_DATA . 'logs/' . $this->compileLogFileName($sLogFileName); $sLogFileFullPath = \trim($this->oConfig->Get('logs', 'path', '')) ?: \APP_PRIVATE_DATA . 'logs';
$oDriver = new \MailSo\Log\Drivers\File($sLogFileFullPath); \is_dir($sLogFileFullPath) || \mkdir($sLogFileFullPath, 0700, true);
$oDriver = new \MailSo\Log\Drivers\File($sLogFileFullPath . '/' . $this->compileLogFileName($sLogFileName));
} }
$this->oLogger->append($oDriver $this->oLogger->append($oDriver
->SetTimeZone($this->oConfig->Get('logs', 'time_zone', 'UTC')) ->SetTimeZone($this->oConfig->Get('logs', 'time_zone', 'UTC'))
@ -509,6 +510,8 @@ class Actions
switch (true) { switch (true) {
default: default:
case $bForceFile: 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( $oDriver = new \MailSo\Cache\Drivers\File(
\trim($this->oConfig->Get('cache', 'path', APP_PRIVATE_DATA . 'cache')), \trim($this->oConfig->Get('cache', 'path', APP_PRIVATE_DATA . 'cache')),
$sKey $sKey
@ -569,13 +572,10 @@ class Actions
if ($this->oConfig->Get('logs', 'auth_logging', false)) { if ($this->oConfig->Get('logs', 'auth_logging', false)) {
// $this->oLoggerAuth->SetLevel(\LOG_WARNING); // $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', '')); . '/' . $this->compileLogFileName($this->oConfig->Get('logs', 'auth_logging_filename', ''));
$sLogFileDir = \dirname($sAuthLogFileFullPath); $sLogFileDir = \dirname($sAuthLogFileFullPath);
if (!\is_dir($sLogFileDir)) { \is_dir($sLogFileDir) || \mkdir($sLogFileDir, 0755, true);
\mkdir($sLogFileDir, 0755, true);
}
$this->oLoggerAuth->append( $this->oLoggerAuth->append(
(new \MailSo\Log\Drivers\File($sAuthLogFileFullPath)) (new \MailSo\Log\Drivers\File($sAuthLogFileFullPath))
->DisableTimePrefix() ->DisableTimePrefix()

View file

@ -135,7 +135,7 @@ if (defined('APP_VERSION'))
clearstatcache(); 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)) if (!is_dir(APP_PRIVATE_DATA.$sName))
{ {