diff --git a/lib/base.php b/lib/base.php index c76d83cd220a2d2459c66818096bc9459eb7b8c1..b9862e7319438c592e451b7e57084d0469444d56 100644 --- a/lib/base.php +++ b/lib/base.php @@ -730,7 +730,6 @@ class OC { self::registerCacheHooks(); self::registerFilesystemHooks(); self::registerShareHooks(); - self::registerLogRotate(); self::registerEncryptionWrapper(); self::registerEncryptionHooks(); self::registerAccountHooks(); @@ -862,18 +861,6 @@ class OC { \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); } - /** - * register hooks for the cache - */ - public static function registerLogRotate() { - $systemConfig = \OC::$server->getSystemConfig(); - if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { - //don't try to do this before we are properly setup - //use custom logfile path if defined, otherwise use default of nextcloud.log in data directory - \OC::$server->getJobList()->add('OC\Log\Rotate'); - } - } - /** * register hooks for the filesystem */ diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 80cd3c7fd45bfc7ed4350d02417d9fe17a4ef8ba..ac824095d5302992da89cb132bba18227bd56dca 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -41,6 +41,7 @@ use OC\Repair\NC11\MoveAvatars; use OC\Repair\NC12\InstallCoreBundle; use OC\Repair\NC12\UpdateLanguageCodes; use OC\Repair\NC12\RepairIdentityProofKeyFolders; +use OC\Repair\NC13\AddLogRotateJob; use OC\Repair\OldGroupMembershipShares; use OC\Repair\Owncloud\DropAccountTermsTable; use OC\Repair\Owncloud\SaveAccountsTableData; @@ -150,6 +151,7 @@ class Repair implements IOutput{ ), new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), new RepairIdentityProofKeyFolders(\OC::$server->getConfig(), \OC::$server->query(Factory::class), \OC::$server->getRootFolder()), + new AddLogRotateJob(\OC::$server->getJobList()), ]; } diff --git a/lib/private/Repair/NC13/AddLogRotateJob.php b/lib/private/Repair/NC13/AddLogRotateJob.php new file mode 100644 index 0000000000000000000000000000000000000000..c65ea47f02bfe5a9c35ba48992251e59bae5df70 --- /dev/null +++ b/lib/private/Repair/NC13/AddLogRotateJob.php @@ -0,0 +1,47 @@ +<?php +/** + * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OC\Repair\NC13; + +use OC\Log\Rotate; +use OCP\BackgroundJob\IJobList; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class AddLogRotateJob implements IRepairStep { + + /** @var IJobList */ + private $jobList; + + public function __construct(IJobList $jobList) { + $this->jobList = $jobList; + } + + public function getName() { + return 'Add log rotate job'; + } + + public function run(IOutput $output) { + $this->jobList->add(Rotate::class); + } + +} diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 5228d52b05fdada7f254dd5792e1fcf090397abf..4e1e4ece62d8a1e7d5b56487cf1e1d3ccbae96fd 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -44,6 +44,7 @@ use Exception; use OC\App\AppStore\Bundles\BundleFetcher; use OC\Authentication\Token\DefaultTokenCleanupJob; use OC\Authentication\Token\DefaultTokenProvider; +use OC\Log\Rotate; use OCP\Defaults; use OCP\IL10N; use OCP\ILogger; @@ -426,7 +427,9 @@ class Setup { } public static function installBackgroundJobs() { - \OC::$server->getJobList()->add(DefaultTokenCleanupJob::class); + $jobList = \OC::$server->getJobList(); + $jobList->add(DefaultTokenCleanupJob::class); + $jobList->add(Rotate::class); } /**