From 88ef163276fc030006a061358f42746b59c489f3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jun 2016 21:34:28 +0200 Subject: handle unavailable fed shares while testing for availability (#25277) * More explicit http status codes * handle unavailable fed shares while testing for availability --- apps/files_sharing/lib/External/Storage.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 29b9c7b563c..bc8d898f8ef 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -32,6 +32,7 @@ use OC\Files\Storage\DAV; use OC\ForbiddenException; use OCA\FederatedFileSharing\DiscoveryManager; use OCA\Files_Sharing\ISharedStorage; +use OCP\AppFramework\Http; use OCP\Files\NotFoundException; use OCP\Files\StorageInvalidException; use OCP\Files\StorageNotAvailableException; @@ -181,6 +182,20 @@ class Storage extends DAV implements ISharedStorage { } } + public function test() { + try { + parent::test(); + } catch (StorageInvalidException $e) { + // check if it needs to be removed + $this->checkStorageAvailability(); + throw $e; + } catch (StorageNotAvailableException $e) { + // check if it needs to be removed or just temp unavailable + $this->checkStorageAvailability(); + throw $e; + } + } + /** * Check whether this storage is permanently or temporarily * unavailable @@ -310,10 +325,10 @@ class Storage extends DAV implements ISharedStorage { 'connect_timeout' => 10, ]); } catch (\GuzzleHttp\Exception\RequestException $e) { - if ($e->getCode() === 401 || $e->getCode() === 403) { + if ($e->getCode() === Http::STATUS_UNAUTHORIZED || $e->getCode() === Http::STATUS_FORBIDDEN) { throw new ForbiddenException(); } - if ($e->getCode() === 404) { + if ($e->getCode() === Http::STATUS_NOT_FOUND) { throw new NotFoundException(); } // throw this to be on the safe side: the share will still be visible -- cgit v1.2.3 From 2a72eff9ee5c337f75e8d0434cd93aada6a38eec Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jun 2016 22:26:43 +0200 Subject: Fix getting the certificate bundle for dav external storage (#25274) * Fix getting the certificate bundle for dav external storages * Log the original exception in dav external storage --- apps/files_sharing/lib/External/Manager.php | 2 +- lib/private/Files/Storage/DAV.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index e338e6e509c..3f665b0978d 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -328,7 +328,7 @@ class Manager { public function removeShare($mountPoint) { $mountPointObj = $this->mountManager->find($mountPoint); - $id = $mountPointObj->getStorage()->getCache()->getId(); + $id = $mountPointObj->getStorage()->getCache()->getId(''); $mountPoint = $this->stripPath($mountPoint); $hash = md5($mountPoint); diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index c8088a41c47..7eb6aa199b1 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -107,7 +107,11 @@ class DAV extends Common { } if ($this->secure === true) { // inject mock for testing - $certPath = \OC_User::getHome(\OC_User::getUser()) . '/files_external/rootcerts.crt'; + $certManager = \OC::$server->getCertificateManager(); + if (is_null($certManager)) { //no user + $certManager = \OC::$server->getCertificateManager(null); + } + $certPath = $certManager->getAbsoluteBundlePath(); if (file_exists($certPath)) { $this->certPath = $certPath; } @@ -812,6 +816,7 @@ class DAV extends Common { * which might be temporary */ private function convertException(Exception $e, $path = '') { + \OC::$server->getLogger()->logException($e); Util::writeLog('files_external', $e->getMessage(), Util::ERROR); if ($e instanceof ClientHttpException) { if ($e->getHttpStatus() === Http::STATUS_LOCKED) { -- cgit v1.2.3