123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace OC\Repair;
- use OC\Avatar\AvatarManager;
- use OCP\IConfig;
- use OCP\BackgroundJob\IJobList;
- use OCP\Migration\IOutput;
- use OCP\Migration\IRepairStep;
- class ClearGeneratedAvatarCache implements IRepairStep {
- protected AvatarManager $avatarManager;
- private IConfig $config;
- private IJobList $jobList;
- public function __construct(IConfig $config, AvatarManager $avatarManager, IJobList $jobList) {
- $this->config = $config;
- $this->avatarManager = $avatarManager;
- $this->jobList = $jobList;
- }
- public function getName(): string {
- return 'Clear every generated avatar';
- }
-
- private function shouldRun(): bool {
- $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
-
-
- return version_compare($versionFromBeforeUpdate, '27.0.0', '<');
- }
- public function run(IOutput $output): void {
- if ($this->shouldRun()) {
- try {
- $this->jobList->add(ClearGeneratedAvatarCacheJob::class, []);
- $output->info('Avatar cache clearing job added');
- } catch (\Exception $e) {
- $output->warning('Unable to clear the avatar cache');
- }
- }
- }
- }
|