Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-08-28 09:27:12 +0300
committerJulius Härtl <jus@bitgrid.net>2020-08-28 14:34:37 +0300
commit249730db5830edb01cc65100ac6dcb36b2f08c36 (patch)
treea483b837ccadc3287c34a6beca99b793dd8566f6 /lib
parent52397462525f4bc4414acf7ca40a015c1304abb3 (diff)
Catch StorageNotAvailable exceptions
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/WorkspaceController.php5
-rw-r--r--lib/DAV/WorkspacePlugin.php11
-rw-r--r--lib/Service/WorkspaceService.php2
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/Controller/WorkspaceController.php b/lib/Controller/WorkspaceController.php
index 1551db69a..6d3ab10f0 100644
--- a/lib/Controller/WorkspaceController.php
+++ b/lib/Controller/WorkspaceController.php
@@ -60,6 +60,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
+use OCP\Files\StorageNotAvailableException;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\Share\Exceptions\ShareNotFound;
@@ -134,6 +135,8 @@ class WorkspaceController extends OCSController {
}
} catch (NotFoundException $e) {
return new DataResponse(['message' => 'No valid folder found'], Http::STATUS_BAD_REQUEST);
+ } catch (StorageNotAvailableException $e) {
+ return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
@@ -167,6 +170,8 @@ class WorkspaceController extends OCSController {
return new DataResponse(['message' => 'No valid folder found'], Http::STATUS_BAD_REQUEST);
} catch (ShareNotFound $e) {
return new DataResponse(['message' => 'No valid folder found'], Http::STATUS_BAD_REQUEST);
+ } catch (StorageNotAvailableException $e) {
+ return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
diff --git a/lib/DAV/WorkspacePlugin.php b/lib/DAV/WorkspacePlugin.php
index c39b5b364..79a8a393a 100644
--- a/lib/DAV/WorkspacePlugin.php
+++ b/lib/DAV/WorkspacePlugin.php
@@ -31,6 +31,7 @@ use OCA\DAV\Files\FilesHome;
use OCA\Text\AppInfo\Application;
use OCA\Text\Service\WorkspaceService;
use OCP\Files\IRootFolder;
+use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use Sabre\DAV\INode;
use Sabre\DAV\PropFind;
@@ -98,9 +99,13 @@ class WorkspacePlugin extends ServerPlugin {
$nodes = $this->rootFolder->getUserFolder($this->userId)->getById($node->getId());
if (count($nodes) > 0) {
/** @var File $file */
- $file = $this->workspaceService->getFile($nodes[0]);
- if ($file instanceof File) {
- return $file->getContent();
+ try {
+ $file = $this->workspaceService->getFile($nodes[0]);
+ if ($file instanceof File) {
+ return $file->getContent();
+ }
+ } catch (StorageNotAvailableException $e) {
+ // If a storage is not available we can for the propfind response assume that there is no rich workspace present
}
}
return '';
diff --git a/lib/Service/WorkspaceService.php b/lib/Service/WorkspaceService.php
index 5e4ff75e7..819900745 100644
--- a/lib/Service/WorkspaceService.php
+++ b/lib/Service/WorkspaceService.php
@@ -6,6 +6,7 @@ namespace OCA\Text\Service;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
+use OCP\Files\StorageNotAvailableException;
use OCP\IL10N;
class WorkspaceService {
@@ -25,6 +26,7 @@ class WorkspaceService {
/**
* @param Folder $folder
+ * @throws StorageNotAvailableException
* @return \OCP\Files\File
*/
public function getFile(Folder $folder) {