From 14a1bdb6e12730ec1e369ec5cffb7e5566b5cb2f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 25 Sep 2019 13:30:40 +0200 Subject: [PATCH] add (hidden) option to configure smb timeout hidden from ui to prevent clutter ```occ files_external:config timeout 30``` Signed-off-by: Robin Appelman --- apps/files_external/lib/Lib/Backend/SMB.php | 2 ++ apps/files_external/lib/Lib/Storage/SMB.php | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/Lib/Backend/SMB.php b/apps/files_external/lib/Lib/Backend/SMB.php index 0543247051..40888d86d2 100644 --- a/apps/files_external/lib/Lib/Backend/SMB.php +++ b/apps/files_external/lib/Lib/Backend/SMB.php @@ -53,6 +53,8 @@ class SMB extends Backend { (new DefinitionParameter('show_hidden', $l->t('Show hidden files'))) ->setType(DefinitionParameter::VALUE_BOOLEAN) ->setFlag(DefinitionParameter::FLAG_OPTIONAL), + (new DefinitionParameter('timeout', $l->t('Timeout'))) + ->setFlag(DefinitionParameter::VALUE_HIDDEN) ]) ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) ->addAuthScheme(AuthMechanism::SCHEME_SMB) diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 85b4e62075..cd6ef5c213 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -44,6 +44,7 @@ use Icewind\SMB\Exception\NotFoundException; use Icewind\SMB\Exception\TimedOutException; use Icewind\SMB\IFileInfo; use Icewind\SMB\Native\NativeServer; +use Icewind\SMB\Options; use Icewind\SMB\ServerFactory; use Icewind\SMB\System; use Icewind\Streams\CallbackWrapper; @@ -106,7 +107,14 @@ class SMB extends Common implements INotifyStorage { $this->logger = \OC::$server->getLogger(); } - $serverFactory = new ServerFactory(); + $options = new Options(); + if (isset($params['timeout'])) { + $timeout = (int)$params['timeout']; + if ($timeout > 0) { + $options->setTimeout($timeout); + } + } + $serverFactory = new ServerFactory($options); $this->server = $serverFactory->createServer($params['host'], $auth); $this->share = $this->server->getShare(trim($params['share'], '/'));