Skip to content

Commit

Permalink
feat: configurable request timeout for carddav sync
Browse files Browse the repository at this point in the history
Big federated setups may need a longer timeout, which they now can
configure.

Signed-off-by: Pablo Zmdl <[email protected]>
Co-authored-by: Josh <[email protected]>
  • Loading branch information
pabzm and joshtrichards committed Oct 2, 2024
1 parent 4f88123 commit 7b1d30c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/dav/lib/CardDAV/SyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCP\AppFramework\Db\TTransactional;
use OCP\AppFramework\Http;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserManager;
Expand All @@ -33,20 +34,23 @@ class SyncService {
private Converter $converter;
protected string $certPath;
private IClientService $clientService;
private IConfig $config;

public function __construct(CardDavBackend $backend,
IUserManager $userManager,
IDBConnection $dbConnection,
LoggerInterface $logger,
Converter $converter,
IClientService $clientService) {
IClientService $clientService,
IConfig $config) {
$this->backend = $backend;
$this->userManager = $userManager;
$this->logger = $logger;
$this->converter = $converter;
$this->certPath = '';
$this->dbConnection = $dbConnection;
$this->clientService = $clientService;
$this->config = $config;
}

/**
Expand Down Expand Up @@ -121,7 +125,8 @@ protected function requestSyncReport(string $url, string $userName, string $addr
'auth' => [$userName, $sharedSecret],
'base_uri' => $url,
'body' => $this->buildSyncCollectionRequestBody($syncToken),
'headers' => ['Content-Type' => 'application/xml']
'headers' => ['Content-Type' => 'application/xml'],
'timeout' => $this->config->getSystemValueInt('carddav_sync_request_timeout', 30)
];

$response = $client->request(
Expand Down
7 changes: 7 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@
*/
'davstorage.request_timeout' => 30,

/**
* The timeout in seconds for synchronizing address books, e.g. federated system address books (as run by `occ federation:sync-addressbooks`).
*
* Defaults to ``30`` seconds
*/
'carddav_sync_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

0 comments on commit 7b1d30c

Please sign in to comment.