From f5dc657e941e23a98ef8f040d61149a671bcb5da Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 5 Mar 2021 14:57:07 +0100 Subject: Move background job to DI Signed-off-by: Roeland Jago Douma --- apps/admin_audit/lib/BackgroundJobs/Rotate.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'apps/admin_audit') diff --git a/apps/admin_audit/lib/BackgroundJobs/Rotate.php b/apps/admin_audit/lib/BackgroundJobs/Rotate.php index 4785993bee1..4244a7e4f9e 100644 --- a/apps/admin_audit/lib/BackgroundJobs/Rotate.php +++ b/apps/admin_audit/lib/BackgroundJobs/Rotate.php @@ -25,26 +25,31 @@ namespace OCA\AdminAudit\BackgroundJobs; use OC\BackgroundJob\TimedJob; +use OCP\IConfig; use OCP\Log\RotationTrait; class Rotate extends TimedJob { use RotationTrait; - public function __construct() { + /** @var IConfig */ + private $config; + + public function __construct(IConfig $config) { + $this->config = $config; + $this->setInterval(60 * 60 * 3); } protected function run($argument) { - $config = \OC::$server->getConfig(); - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; - $this->filePath = $config->getAppValue('admin_audit', 'logfile', $default); + $default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; + $this->filePath = $this->config->getAppValue('admin_audit', 'logfile', $default); if ($this->filePath === '') { // default log file, nothing to do return; } - $this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); + $this->maxSize = $this->config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); if ($this->shouldRotateBySize()) { $this->rotate(); -- cgit v1.2.3