add (hidden) option to configure smb timeout

hidden from ui to prevent clutter

```occ files_external:config <mount> timeout 30```

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2019-09-25 13:30:40 +02:00
parent 507eb30e1d
commit 194edfc64e
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
2 changed files with 11 additions and 1 deletions

View File

@ -53,6 +53,8 @@ class SMB extends Backend {
(new DefinitionParameter('show_hidden', $l->t('Show hidden files'))) (new DefinitionParameter('show_hidden', $l->t('Show hidden files')))
->setType(DefinitionParameter::VALUE_BOOLEAN) ->setType(DefinitionParameter::VALUE_BOOLEAN)
->setFlag(DefinitionParameter::FLAG_OPTIONAL), ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
(new DefinitionParameter('timeout', $l->t('Timeout')))
->setFlag(DefinitionParameter::VALUE_HIDDEN)
]) ])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->addAuthScheme(AuthMechanism::SCHEME_SMB) ->addAuthScheme(AuthMechanism::SCHEME_SMB)

View File

@ -44,6 +44,7 @@ use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\Exception\TimedOutException; use Icewind\SMB\Exception\TimedOutException;
use Icewind\SMB\IFileInfo; use Icewind\SMB\IFileInfo;
use Icewind\SMB\Native\NativeServer; use Icewind\SMB\Native\NativeServer;
use Icewind\SMB\Options;
use Icewind\SMB\ServerFactory; use Icewind\SMB\ServerFactory;
use Icewind\SMB\System; use Icewind\SMB\System;
use Icewind\Streams\CallbackWrapper; use Icewind\Streams\CallbackWrapper;
@ -105,7 +106,14 @@ class SMB extends Common implements INotifyStorage {
$this->logger = \OC::$server->getLogger(); $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->server = $serverFactory->createServer($params['host'], $auth);
$this->share = $this->server->getShare(trim($params['share'], '/')); $this->share = $this->server->getShare(trim($params['share'], '/'));