Files
nextcloud-server-mirror/apps/files_sharing/lib/BackgroundJob/ExternalShareScanJob.php
Carl Schwan f7da7e6bcb fix: Don't add empty and broken ExternalShareScanJob on upgrade
This is added manually in
apps/files_sharing/lib/Controller/ExternalSharesController.php when
needed and with arguments.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2026-07-22 15:37:40 +02:00

54 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_Sharing\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\Files\IRootFolder;
use OCP\IConfig;
use Psr\Log\LoggerInterface;
/**
* Scans an external share with a specific path
*/
class ExternalShareScanJob extends QueuedJob {
public function __construct(
private readonly IConfig $config,
private readonly IRootFolder $rootFolder,
private readonly LoggerInterface $logger,
ITimeFactory $time,
) {
parent::__construct($time);
}
#[\Override]
protected function run($argument): void {
if ($this->config->getSystemValueBool('files_no_background_scan', false)) {
return;
}
[$userId, $path] = $argument;
if ($userId === null || $userId === '') {
return;
}
try {
$this->rootFolder
->getUserFolder($userId)
->get($path)
->getStorage()
->getScanner()
->scan('');
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), [ 'exception' => $e ]);
}
}
}