Skip to content

Commit

Permalink
Added AppDataUpdate repair step to sync settings changes on app update (
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey18106 authored Dec 23, 2022
1 parent c79426b commit f2e1563
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ You can support us in several ways:
<nextcloud min-version="25" max-version="26" />
</dependencies>
<repair-steps>
<post-migration>
<step>OCA\Cloud_Py_API\Migration\AppUpdateStep</step>
</post-migration>
<install>
<step>OCA\Cloud_Py_API\Migration\AppDataInitializationStep</step>
</install>
Expand Down
58 changes: 58 additions & 0 deletions lib/Migration/AppUpdateStep.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2022-2023 Andrey Borysenko <[email protected]>
*
* @copyright Copyright (c) 2022-2023 Alexander Piskun <[email protected]>
*
* @author 2022-2023 Andrey Borysenko <[email protected]>
*
* @license AGPL-3.0-or-later
*
* 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 OCA\Cloud_Py_API\Migration;

use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

use OCA\Cloud_Py_API\Migration\data\AppInitialData;
use OCA\Cloud_Py_API\Service\UtilsService;

class AppUpdateStep implements IRepairStep {
/** @var UtilsService */
private $utils;

public function __construct(UtilsService $utils) {
$this->utils = $utils;
}

public function getName(): string {
return "Updating Cloud_Py_API data";
}

public function run(IOutput $output) {
$output->startProgress(1);
$app_data = AppInitialData::$INITIAL_DATA;

$output->advance(1, 'Checking for inital data changes and syncing with database');
$this->utils->checkForSettingsUpdates($app_data);

$output->finishProgress();
}
}

0 comments on commit f2e1563

Please sign in to comment.