diff options
author | Robin Appelman <robin@icewind.nl> | 2024-09-27 15:41:26 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-10-04 15:56:31 +0200 |
commit | 103b464eea63a678ab420f1d2f7c7cb74bdb9b71 (patch) | |
tree | 8c8b86db3a5f3832e10c6baa482516b2fff09c6b /apps/files_external/lib/Lib | |
parent | 53b1bc5eb71547905e461bb6b207cfeca03f3466 (diff) | |
download | nextcloud-server-103b464eea63a678ab420f1d2f7c7cb74bdb9b71.tar.gz nextcloud-server-103b464eea63a678ab420f1d2f7c7cb74bdb9b71.zip |
fix: use nc's binary finding logic for smbsmb-systembridge
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SMB.php | 14 | ||||
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SystemBridge.php | 27 |
2 files changed, 34 insertions, 7 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 4f1f51f1bf9..4fd64cd8ea0 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -4,6 +4,7 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + namespace OCA\Files_External\Lib\Storage; use Icewind\SMB\ACL; @@ -21,7 +22,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; @@ -92,7 +93,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(); @@ -102,7 +103,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'], '/')); @@ -697,10 +699,8 @@ class SMB extends Common implements INotifyStorage { * check if smbclient is installed */ public static function checkDependencies(): array|bool { - return ( - (bool)\OC_Helper::findBinaryPath('smbclient') - || NativeServer::available(new System()) - ) ? true : ['smbclient']; + $system = \OCP\Server::get(SystemBridge::class); + return Server::available($system) || NativeServer::available($system) ?: ['smbclient']; } public function test(): bool { diff --git a/apps/files_external/lib/Lib/Storage/SystemBridge.php b/apps/files_external/lib/Lib/Storage/SystemBridge.php new file mode 100644 index 00000000000..80449b2744b --- /dev/null +++ b/apps/files_external/lib/Lib/Storage/SystemBridge.php @@ -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; + } +} |