Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/dav/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<step>OCA\DAV\Migration\RemoveOrphanEventsAndContacts</step>
<step>OCA\DAV\Migration\RemoveClassifiedEventActivity</step>
<step>OCA\DAV\Migration\RemoveDeletedUsersCalendarSubscriptions</step>
<!-- expensive steps -->
<step>OCA\DAV\Migration\DeleteSchedulingObjects</step>
<step>OCA\DAV\Migration\RemoveObjectProperties</step>
</post-migration>
<live-migration>
<step>OCA\DAV\Migration\ChunkCleanup</step>
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Migration/DeleteSchedulingObjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Migration\IRepairStepExpensive;

class DeleteSchedulingObjects implements IRepairStep {
class DeleteSchedulingObjects implements IRepairStepExpensive {
public function __construct(
private IJobList $jobList,
private ITimeFactory $time,
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Migration/RemoveObjectProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Migration\IRepairStepExpensive;

class RemoveObjectProperties implements IRepairStep {
class RemoveObjectProperties implements IRepairStepExpensive {
private const RESOURCE_TYPE_PROPERTY = '{DAV:}resourcetype';
private const ME_CARD_PROPERTY = '{http://calendarserver.org/ns/}me-card';
private const CALENDAR_TRANSP_PROPERTY = '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp';
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Turning the feature off removes shared files and folders on the server for all s
<step>OCA\Files_Sharing\Migration\OwncloudGuestShareType</step>
<step>OCA\Files_Sharing\Migration\SetPasswordColumn</step>
<step>OCA\Files_Sharing\Migration\SetAcceptedStatus</step>
<!-- expensive steps -->
<step>OCA\Files_Sharing\Repair\CleanupShareTarget</step>
</post-migration>
</repair-steps>

Expand Down
11 changes: 4 additions & 7 deletions core/Command/Maintenance/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ protected function configure(): void {
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$repairSteps = $this->repair::getRepairSteps();

if ($input->getOption('include-expensive')) {
$repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps());
}
$includeExpensive = (bool)$input->getOption('include-expensive');
$repairSteps = $this->repair::getRepairSteps($includeExpensive);

foreach ($repairSteps as $step) {
$this->repair->addStep($step);
$this->repair->addStep($step, $includeExpensive);
}

$apps = $this->appManager->getEnabledApps();
Expand All @@ -74,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$steps = $info['repair-steps']['post-migration'];
foreach ($steps as $step) {
try {
$this->repair->addStep($step);
$this->repair->addStep($step, $includeExpensive);
} catch (Exception $ex) {
$output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>");
}
Expand Down
3 changes: 2 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@
'OCP\\Migration\\IMigrationStep' => $baseDir . '/lib/public/Migration/IMigrationStep.php',
'OCP\\Migration\\IOutput' => $baseDir . '/lib/public/Migration/IOutput.php',
'OCP\\Migration\\IRepairStep' => $baseDir . '/lib/public/Migration/IRepairStep.php',
'OCP\\Migration\\IRepairStepExpensive' => $baseDir . '/lib/public/Migration/IRepairStepExpensive.php',
'OCP\\Migration\\SimpleMigrationStep' => $baseDir . '/lib/public/Migration/SimpleMigrationStep.php',
'OCP\\Navigation\\Events\\LoadAdditionalEntriesEvent' => $baseDir . '/lib/public/Navigation/Events/LoadAdditionalEntriesEvent.php',
'OCP\\Notification\\AlreadyProcessedException' => $baseDir . '/lib/public/Notification/AlreadyProcessedException.php',
Expand Down Expand Up @@ -2061,7 +2062,7 @@
'OC\\Repair\\MoveUpdaterStepFile' => $baseDir . '/lib/private/Repair/MoveUpdaterStepFile.php',
'OC\\Repair\\NC13\\AddLogRotateJob' => $baseDir . '/lib/private/Repair/NC13/AddLogRotateJob.php',
'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => $baseDir . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php',
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
'OC\\Repair\\NC16\\AddCleanupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php',
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => $baseDir . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
'OC\\Repair\\NC16\\ClearCollectionsAccessCache' => $baseDir . '/lib/private/Repair/NC16/ClearCollectionsAccessCache.php',
'OC\\Repair\\NC18\\ResetGeneratedAvatarFlag' => $baseDir . '/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php',
Expand Down
3 changes: 2 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Migration\\IMigrationStep' => __DIR__ . '/../../..' . '/lib/public/Migration/IMigrationStep.php',
'OCP\\Migration\\IOutput' => __DIR__ . '/../../..' . '/lib/public/Migration/IOutput.php',
'OCP\\Migration\\IRepairStep' => __DIR__ . '/../../..' . '/lib/public/Migration/IRepairStep.php',
'OCP\\Migration\\IRepairStepExpensive' => __DIR__ . '/../../..' . '/lib/public/Migration/IRepairStepExpensive.php',
'OCP\\Migration\\SimpleMigrationStep' => __DIR__ . '/../../..' . '/lib/public/Migration/SimpleMigrationStep.php',
'OCP\\Navigation\\Events\\LoadAdditionalEntriesEvent' => __DIR__ . '/../../..' . '/lib/public/Navigation/Events/LoadAdditionalEntriesEvent.php',
'OCP\\Notification\\AlreadyProcessedException' => __DIR__ . '/../../..' . '/lib/public/Notification/AlreadyProcessedException.php',
Expand Down Expand Up @@ -2102,7 +2103,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Repair\\MoveUpdaterStepFile' => __DIR__ . '/../../..' . '/lib/private/Repair/MoveUpdaterStepFile.php',
'OC\\Repair\\NC13\\AddLogRotateJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC13/AddLogRotateJob.php',
'OC\\Repair\\NC14\\AddPreviewBackgroundCleanupJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php',
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
'OC\\Repair\\NC16\\AddCleanupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php',
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
'OC\\Repair\\NC16\\ClearCollectionsAccessCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/ClearCollectionsAccessCache.php',
'OC\\Repair\\NC18\\ResetGeneratedAvatarFlag' => __DIR__ . '/../../..' . '/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php',
Expand Down
60 changes: 27 additions & 33 deletions lib/private/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use OC\Repair\MoveUpdaterStepFile;
use OC\Repair\NC13\AddLogRotateJob;
use OC\Repair\NC14\AddPreviewBackgroundCleanupJob;
use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob;
use OC\Repair\NC16\AddCleanupLoginFlowV2BackgroundJob;
use OC\Repair\NC16\CleanupCardDAVPhotoCache;
use OC\Repair\NC16\ClearCollectionsAccessCache;
use OC\Repair\NC18\ResetGeneratedAvatarFlag;
Expand All @@ -56,14 +56,12 @@
use OC\Repair\RepairInvalidShares;
use OC\Repair\RepairLogoDimension;
use OC\Repair\RepairMimeTypes;
use OCA\DAV\Migration\DeleteSchedulingObjects;
use OCA\DAV\Migration\RemoveObjectProperties;
use OCA\Files_Sharing\Repair\CleanupShareTarget;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Migration\IRepairStepExpensive;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -113,10 +111,11 @@ public function run(): void {
/**
* Add repair step
*
* @param IRepairStep|class-string<IRepairStep> $repairStep repair step
* @param IRepairStep|class-string<IRepairStep> $repairStep Repair step
* @param bool $includeExpensive Whether to include expensive repair steps, defaults to false
* @throws \Exception
*/
public function addStep(IRepairStep|string $repairStep): void {
public function addStep(IRepairStep|string $repairStep, bool $includeExpensive = false): void {
if (is_string($repairStep)) {
try {
$s = Server::get($repairStep);
Expand All @@ -134,24 +133,30 @@ public function addStep(IRepairStep|string $repairStep): void {
}
}

if ($s instanceof IRepairStep) {
$this->repairSteps[] = $s;
} else {
if (!($s instanceof IRepairStep)) {
throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
}

$repairStep = $s;
}

if (($repairStep instanceof IRepairStepExpensive) && !$includeExpensive) {
$this->debug("Skipping expensive repair step '" . $repairStep::class . "'");
} else {
$this->repairSteps[] = $repairStep;
}
}

/**
* Returns the default repair steps to be run on the
* command line or after an upgrade.
* Returns the core repair steps to be run on the command line or after an upgrade.
*
* @param bool $includeExpensive Whether to include expensive repair steps, defaults to false
* @return list<IRepairStep>
*
* @since 34.0.0, the $includeExpensive parameter was added
*/
public static function getRepairSteps(): array {
return [
public static function getRepairSteps(bool $includeExpensive = false): array {
$repairSteps = [
new Collation(Server::get(IConfig::class), Server::get(LoggerInterface::class), Server::get(IDBConnection::class), false),
Server::get(CleanTags::class),
Server::get(RepairInvalidShares::class),
Expand All @@ -167,7 +172,7 @@ public static function getRepairSteps(): array {
Server::get(AddPreviewBackgroundCleanupJob::class),
Server::get(AddCleanupUpdaterBackupsJob::class),
Server::get(CleanupCardDAVPhotoCache::class),
Server::get(AddClenupLoginFlowV2BackgroundJob::class),
Server::get(AddCleanupLoginFlowV2BackgroundJob::class),
Server::get(RemoveLinkShares::class),
Server::get(ClearCollectionsAccessCache::class),
Server::get(ResetGeneratedAvatarFlag::class),
Expand All @@ -190,28 +195,17 @@ public static function getRepairSteps(): array {
Server::get(AddMovePreviewJob::class),
Server::get(ConfigKeyMigration::class),
];
}

/**
* Returns expensive repair steps to be run on the
* command line with a special option.
*
* @return list<IRepairStep>
*/
public static function getExpensiveRepairSteps(): array {
$expensiveSteps = [
Server::get(OldGroupMembershipShares::class),
Server::get(RemoveBrokenProperties::class),
Server::get(RepairMimeTypes::class),
Server::get(DeleteSchedulingObjects::class),
Server::get(RemoveObjectProperties::class),
];

if (class_exists(CleanupShareTarget::class)) {
$expensiveSteps[] = Server::get(CleanupShareTarget::class);
if ($includeExpensive) {
$expensiveSteps = [
Server::get(OldGroupMembershipShares::class),
Server::get(RemoveBrokenProperties::class),
Server::get(RepairMimeTypes::class),
];
$repairSteps = array_merge($repairSteps, $expensiveSteps);
}

return $expensiveSteps;
return $repairSteps;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class AddClenupLoginFlowV2BackgroundJob implements IRepairStep {
class AddCleanupLoginFlowV2BackgroundJob implements IRepairStep {
public function __construct(
private IJobList $jobList,
) {
Expand Down
20 changes: 20 additions & 0 deletions lib/public/Migration/IRepairStepExpensive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Migration;

/**
* Expensive repair steps are non-critical repair steps that might take a long time to execute.
* Non-critical means that they are not required to directly be executed during migration to have a working instance,
* but they might be required to have a fully working instance later on.
*
* Expensive repair steps are only executed when explicitly requested by the administrator.
*
* @since 34.0.0
*/
interface IRepairStepExpensive extends IRepairStep {
}
Loading