Skip to content

Commit 6ea7b01

Browse files
committed
fix: Remove discovery fallback in external storage
If the OCM discovery throws an exception, let that bubble up into a FailedStorage instead of trying to be smart. This avoids unnecessary requests to badly configured or offline servers. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent cbc9f1a commit 6ea7b01

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

apps/files_sharing/lib/External/Storage.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
use OCP\ICacheFactory;
3636
use OCP\IConfig;
3737
use OCP\IUserSession;
38-
use OCP\OCM\Exceptions\OCMArgumentException;
39-
use OCP\OCM\Exceptions\OCMProviderException;
4038
use OCP\OCM\IOCMDiscoveryService;
4139
use OCP\Server;
4240
use OCP\Share\IManager as IShareManager;
@@ -78,18 +76,10 @@ public function __construct($options) {
7876
$this->appConfig = Server::get(IAppConfig::class);
7977
$this->shareManager = Server::get(IShareManager::class);
8078

81-
// use default path to webdav if not found on discovery
82-
try {
83-
$ocmProvider = $discoveryService->discover($this->cloudId->getRemote());
84-
$webDavEndpoint = $ocmProvider->extractProtocolEntry('file', 'webdav');
85-
$remote = $ocmProvider->getEndPoint();
86-
$authType = \Sabre\DAV\Client::AUTH_BASIC;
87-
} catch (OCMProviderException|OCMArgumentException $e) {
88-
$this->logger->notice('exception while retrieving webdav endpoint', ['exception' => $e]);
89-
$webDavEndpoint = '/public.php/webdav';
90-
$remote = $this->cloudId->getRemote();
91-
$authType = \Sabre\DAV\Client::AUTH_BASIC;
92-
}
79+
$ocmProvider = $discoveryService->discover($this->cloudId->getRemote());
80+
$webDavEndpoint = $ocmProvider->extractProtocolEntry('file', 'webdav');
81+
$remote = $ocmProvider->getEndPoint();
82+
$authType = \Sabre\DAV\Client::AUTH_BASIC;
9383

9484
// Only use Bearer auth when an access token is already stored.
9585
// Shares created before the exchange-token capability was introduced have no

0 commit comments

Comments
 (0)