123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace OC\Migration;
- use OCP\AppFramework\Utility\ITimeFactory;
- use OCP\BackgroundJob\IJobList;
- use OCP\BackgroundJob\TimedJob;
- use OCP\EventDispatcher\IEventDispatcher;
- use OC\NeedsUpdateException;
- use OC\Repair;
- use OC_App;
- use Psr\Log\LoggerInterface;
- class BackgroundRepair extends TimedJob {
- private IJobList $jobList;
- private LoggerInterface $logger;
- private IEventDispatcher $dispatcher;
- public function __construct(IEventDispatcher $dispatcher, ITimeFactory $time, LoggerInterface $logger, IJobList $jobList) {
- parent::__construct($time);
- $this->dispatcher = $dispatcher;
- $this->logger = $logger;
- $this->jobList = $jobList;
- $this->setInterval(15 * 60);
- }
-
- protected function run($argument) {
- if (!isset($argument['app']) || !isset($argument['step'])) {
-
- $this->jobList->remove($this, $this->argument);
- return;
- }
- $app = $argument['app'];
- try {
- $this->loadApp($app);
- } catch (NeedsUpdateException $ex) {
-
-
- return;
- }
- $step = $argument['step'];
- $repair = new Repair([], $this->dispatcher, \OC::$server->get(LoggerInterface::class));
- try {
- $repair->addStep($step);
- } catch (\Exception $ex) {
- $this->logger->error($ex->getMessage(), [
- 'app' => 'migration',
- 'exception' => $ex,
- ]);
-
- $this->jobList->remove($this, $this->argument);
- return;
- }
-
- $repair->run();
-
- $this->jobList->remove($this, $this->argument);
- }
-
- protected function loadApp($app) {
- OC_App::loadApp($app);
- }
- }
|