diff options
author | Simon L <szaimen@e.mail.de> | 2023-06-15 12:39:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-15 12:39:50 +0200 |
commit | 630e4835f070d99d7c7f410b05f13b9b10f1265e (patch) | |
tree | dd648294d4f216ebc3f57074daecc0846f350bcc | |
parent | 15a2bd11315966992315420698fe423a88d86921 (diff) | |
parent | 681d2c04028e5ebb4dec221bcd33eade6ca0fe8a (diff) | |
download | nextcloud-server-630e4835f070d99d7c7f410b05f13b9b10f1265e.tar.gz nextcloud-server-630e4835f070d99d7c7f410b05f13b9b10f1265e.zip |
Merge pull request #38825 from nextcloud/backport/38292/stable27
[stable27] Add config variable for curl timeout
-rw-r--r-- | config/config.sample.php | 5 | ||||
-rw-r--r-- | lib/private/Files/Storage/DAV.php | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/config/config.sample.php b/config/config.sample.php index 7a6d2152662..b0aac34c066 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -290,6 +290,11 @@ $CONFIG = [ 'session_lifetime' => 60 * 60 * 24, /** + * The timeout in seconds for requests to servers made by the DAV component (e.g., needed for federated shares). + */ +'davstorage.request_timeout' => 30, + +/** * `true` enabled a relaxed session timeout, where the session timeout would no longer be * handled by Nextcloud but by either the PHP garbage collection or the expiration of * potential other session backends like redis. diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index a791db651c3..e2ad2a18f6b 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -51,6 +51,7 @@ use OCP\Files\StorageInvalidException; use OCP\Files\StorageNotAvailableException; use OCP\Http\Client\IClientService; use OCP\ICertificateManager; +use OCP\IConfig; use OCP\Util; use Psr\Http\Message\ResponseInterface; use Sabre\DAV\Client; @@ -93,6 +94,9 @@ class DAV extends Common { protected LoggerInterface $logger; protected IEventLogger $eventLogger; + /** @var int */ + private $timeout; + /** * @param array $params * @throws \Exception @@ -135,6 +139,8 @@ class DAV extends Common { } $this->logger = \OC::$server->get(LoggerInterface::class); $this->eventLogger = \OC::$server->get(IEventLogger::class); + // This timeout value will be used for the download and upload of files + $this->timeout = \OC::$server->get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', 30); } protected function init() { @@ -373,7 +379,9 @@ class DAV extends Common { ->newClient() ->get($this->createBaseUri() . $this->encodePath($path), [ 'auth' => [$this->user, $this->password], - 'stream' => true + 'stream' => true, + // set download timeout for users with slow connections or large files + 'timeout' => $this->timeout ]); } catch (\GuzzleHttp\Exception\ClientException $e) { if ($e->getResponse() instanceof ResponseInterface @@ -530,7 +538,9 @@ class DAV extends Common { ->newClient() ->put($this->createBaseUri() . $this->encodePath($target), [ 'body' => $source, - 'auth' => [$this->user, $this->password] + 'auth' => [$this->user, $this->password], + // set upload timeout for users with slow connections or large files + 'timeout' => $this->timeout ]); $this->removeCachedFile($target); |