mirror of
https://github.com/nextcloud/server.git
synced 2026-04-27 09:08:22 -04:00
fix: use nc's binary finding logic for smb
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
85f2161031
commit
ae4b127daa
6 changed files with 39 additions and 9 deletions
|
|
@ -97,6 +97,7 @@ return array(
|
|||
'OCA\\Files_External\\Lib\\Storage\\SMB' => $baseDir . '/../lib/Lib/Storage/SMB.php',
|
||||
'OCA\\Files_External\\Lib\\Storage\\StreamWrapper' => $baseDir . '/../lib/Lib/Storage/StreamWrapper.php',
|
||||
'OCA\\Files_External\\Lib\\Storage\\Swift' => $baseDir . '/../lib/Lib/Storage/Swift.php',
|
||||
'OCA\\Files_External\\Lib\\Storage\\SystemBridge' => $baseDir . '/../lib/Lib/Storage/SystemBridge.php',
|
||||
'OCA\\Files_External\\Lib\\VisibilityTrait' => $baseDir . '/../lib/Lib/VisibilityTrait.php',
|
||||
'OCA\\Files_External\\Listener\\GroupDeletedListener' => $baseDir . '/../lib/Listener/GroupDeletedListener.php',
|
||||
'OCA\\Files_External\\Listener\\LoadAdditionalListener' => $baseDir . '/../lib/Listener/LoadAdditionalListener.php',
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ class ComposerStaticInitFiles_External
|
|||
'OCA\\Files_External\\Lib\\Storage\\SMB' => __DIR__ . '/..' . '/../lib/Lib/Storage/SMB.php',
|
||||
'OCA\\Files_External\\Lib\\Storage\\StreamWrapper' => __DIR__ . '/..' . '/../lib/Lib/Storage/StreamWrapper.php',
|
||||
'OCA\\Files_External\\Lib\\Storage\\Swift' => __DIR__ . '/..' . '/../lib/Lib/Storage/Swift.php',
|
||||
'OCA\\Files_External\\Lib\\Storage\\SystemBridge' => __DIR__ . '/..' . '/../lib/Lib/Storage/SystemBridge.php',
|
||||
'OCA\\Files_External\\Lib\\VisibilityTrait' => __DIR__ . '/..' . '/../lib/Lib/VisibilityTrait.php',
|
||||
'OCA\\Files_External\\Listener\\GroupDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/GroupDeletedListener.php',
|
||||
'OCA\\Files_External\\Listener\\LoadAdditionalListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalListener.php',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace OCA\Files_External\Lib\Storage;
|
||||
|
||||
use Icewind\SMB\ACL;
|
||||
|
|
@ -22,7 +23,7 @@ use Icewind\SMB\IFileInfo;
|
|||
use Icewind\SMB\Native\NativeServer;
|
||||
use Icewind\SMB\Options;
|
||||
use Icewind\SMB\ServerFactory;
|
||||
use Icewind\SMB\System;
|
||||
use Icewind\SMB\Wrapped\Server;
|
||||
use Icewind\Streams\CallbackWrapper;
|
||||
use Icewind\Streams\IteratorDirectory;
|
||||
use OC\Files\Filesystem;
|
||||
|
|
@ -93,7 +94,7 @@ class SMB extends Common implements INotifyStorage {
|
|||
}
|
||||
$this->logger = $params['logger'];
|
||||
} else {
|
||||
$this->logger = \OC::$server->get(LoggerInterface::class);
|
||||
$this->logger = \OCP\Server::get(LoggerInterface::class);
|
||||
}
|
||||
|
||||
$options = new Options();
|
||||
|
|
@ -103,7 +104,8 @@ class SMB extends Common implements INotifyStorage {
|
|||
$options->setTimeout($timeout);
|
||||
}
|
||||
}
|
||||
$serverFactory = new ServerFactory($options);
|
||||
$system = \OCP\Server::get(SystemBridge::class);
|
||||
$serverFactory = new ServerFactory($options, $system);
|
||||
$this->server = $serverFactory->createServer($params['host'], $auth);
|
||||
$this->share = $this->server->getShare(trim($params['share'], '/'));
|
||||
|
||||
|
|
@ -721,11 +723,9 @@ class SMB extends Common implements INotifyStorage {
|
|||
/**
|
||||
* check if smbclient is installed
|
||||
*/
|
||||
public static function checkDependencies() {
|
||||
return (
|
||||
(bool) \OC_Helper::findBinaryPath('smbclient')
|
||||
|| NativeServer::available(new System())
|
||||
) ? true : ['smbclient'];
|
||||
public static function checkDependencies(): array|bool {
|
||||
$system = \OCP\Server::get(SystemBridge::class);
|
||||
return Server::available($system) || NativeServer::available($system) ?: ['smbclient'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
27
apps/files_external/lib/Lib/Storage/SystemBridge.php
Normal file
27
apps/files_external/lib/Lib/Storage/SystemBridge.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2024 Robin Appelman <robin@icewind.nl>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Files_External\Lib\Storage;
|
||||
|
||||
use Icewind\SMB\System;
|
||||
use OCP\IBinaryFinder;
|
||||
|
||||
/**
|
||||
* Bridge the NC and SMB binary finding logic
|
||||
*/
|
||||
class SystemBridge extends System {
|
||||
public function __construct(
|
||||
private IBinaryFinder $binaryFinder,
|
||||
) {
|
||||
}
|
||||
|
||||
protected function getBinaryPath(string $binary): ?string {
|
||||
$path = $this->binaryFinder->findBinaryPath($binary);
|
||||
return $path !== false ? $path : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace OCP;
|
|||
/**
|
||||
* Service that find the binary path for a program.
|
||||
*
|
||||
* This interface should be injected via depency injection and must
|
||||
* This interface should be injected via dependency injection and must
|
||||
* not be implemented in applications.
|
||||
*
|
||||
* @since 25.0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue