diff --git a/config/config.sample.php b/config/config.sample.php index 94b8a5d055245..c87e1cad9fa4c 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -289,6 +289,11 @@ */ '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 diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 733aa10cde6d2..b5b8b548787ef 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -51,6 +51,7 @@ 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 @@ public function __construct($params) { } $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 @@ public function fopen($path, $mode) { ->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 @@ protected function uploadFile($path, $target) { ->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);