2020-12-07 08:30:08 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2020-12-07 08:30:08 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-12-07 08:30:08 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Repair\Owncloud;
|
|
|
|
|
|
|
|
|
|
use OCP\BackgroundJob\IJobList;
|
2025-12-02 05:39:50 -05:00
|
|
|
use OCP\IAppConfig;
|
2020-12-07 08:30:08 -05:00
|
|
|
use OCP\IUser;
|
|
|
|
|
use OCP\IUserManager;
|
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
|
use OCP\Migration\IRepairStep;
|
2025-12-02 05:39:50 -05:00
|
|
|
use Override;
|
2020-12-07 08:30:08 -05:00
|
|
|
|
|
|
|
|
class CleanPreviews implements IRepairStep {
|
2025-11-17 09:32:54 -05:00
|
|
|
public function __construct(
|
2025-11-24 03:17:34 -05:00
|
|
|
private readonly IJobList $jobList,
|
|
|
|
|
private readonly IUserManager $userManager,
|
2025-12-02 05:39:50 -05:00
|
|
|
private readonly IAppConfig $appConfig,
|
2025-11-17 09:32:54 -05:00
|
|
|
) {
|
2020-12-07 08:30:08 -05:00
|
|
|
}
|
|
|
|
|
|
2025-12-02 05:39:50 -05:00
|
|
|
#[Override]
|
2025-11-24 03:17:34 -05:00
|
|
|
public function getName(): string {
|
2020-12-07 08:30:08 -05:00
|
|
|
return 'Add preview cleanup background jobs';
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-02 05:39:50 -05:00
|
|
|
#[Override]
|
2025-11-24 03:17:34 -05:00
|
|
|
public function run(IOutput $output): void {
|
2025-12-02 05:39:50 -05:00
|
|
|
if (!$this->appConfig->getValueBool('core', 'previewsCleanedUp')) {
|
2025-11-17 09:32:54 -05:00
|
|
|
$this->userManager->callForSeenUsers(function (IUser $user): void {
|
2020-12-07 08:30:08 -05:00
|
|
|
$this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
|
|
|
|
|
});
|
2025-12-02 05:39:50 -05:00
|
|
|
$this->appConfig->setValueBool('core', 'previewsCleanedUp', true);
|
2020-12-07 08:30:08 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|