Skip to content

Commit

Permalink
fix(migration): Don't redo app initialisation
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Aug 26, 2024
1 parent 2609f3d commit 1b9cc25
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/Migration/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

namespace OCA\QuotaWarning\Migration;

use OCA\QuotaWarning\AppInfo\Application;
use OCA\QuotaWarning\Job\User;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Migration\IOutput;
Expand All @@ -37,11 +39,17 @@ class Install implements IRepairStep {

/** @var IJobList */
protected $jobList;
/** @var IConfig */
protected $config;

public function __construct(IUserManager $userManager,
IJobList $jobList) {
public function __construct(
IUserManager $userManager,
IJobList $jobList,
IConfig $config,
) {
$this->userManager = $userManager;
$this->jobList = $jobList;
$this->config = $config;
}

/**
Expand All @@ -59,6 +67,10 @@ public function getName(): string {
* @since 9.1.0
*/
public function run(IOutput $output): void {
if ($this->config->getAppValue(Application::APP_ID, 'initialised', 'no') === 'yes') {
return;
}

$output->startProgress();
$this->userManager->callForSeenUsers(function (IUser $user) use ($output) {
$this->jobList->add(
Expand All @@ -68,5 +80,7 @@ public function run(IOutput $output): void {
$output->advance();
});
$output->finishProgress();

$this->config->setAppValue(Application::APP_ID, 'initialised', 'yes');
}
}

0 comments on commit 1b9cc25

Please sign in to comment.