Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,6 +94,9 @@ class DAV extends Common {
protected LoggerInterface $logger;
protected IEventLogger $eventLogger;

/** @var int */
private $timeout;

/**
* @param array $params
* @throws \Exception
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down