You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextcloud-server/apps/files_sharing/lib/BackgroundJob/ExternalShareScanJob.php

53 lines
1.1 KiB

<?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 ]);
}
}
}