Skip to content

Commit

Permalink
Merge pull request #17258 from nextcloud/smb-timeout-config
Browse files Browse the repository at this point in the history
add (hidden) option to configure smb timeout
  • Loading branch information
rullzer committed Sep 27, 2019
2 parents f23d492 + bc16099 commit 88b6dc5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/files_external/lib/Lib/Backend/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function __construct(IL10N $l, Password $legacyAuth) {
(new DefinitionParameter('show_hidden', $l->t('Show hidden files')))
->setType(DefinitionParameter::VALUE_BOOLEAN)
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
(new DefinitionParameter('timeout', $l->t('Timeout')))
->setType(DefinitionParameter::VALUE_HIDDEN)
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->addAuthScheme(AuthMechanism::SCHEME_SMB)
Expand Down
10 changes: 9 additions & 1 deletion apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
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;
Expand Down Expand Up @@ -106,7 +107,14 @@ public function __construct($params) {
$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'], '/'));

Expand Down

0 comments on commit 88b6dc5

Please sign in to comment.