Skip to content

Commit 4cc0410

Browse files
authored
Merge pull request #993 from nextcloud/bugfix/992
Catch StorageNotAvailable exceptions
2 parents e62d7a0 + 249730d commit 4cc0410

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

lib/Controller/WorkspaceController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
use OCP\Files\Folder;
6161
use OCP\Files\IRootFolder;
6262
use OCP\Files\NotFoundException;
63+
use OCP\Files\StorageNotAvailableException;
6364
use OCP\IRequest;
6465
use OCP\IURLGenerator;
6566
use OCP\Share\Exceptions\ShareNotFound;
@@ -134,6 +135,8 @@ public function folder(string $path = '/'): DataResponse {
134135
}
135136
} catch (NotFoundException $e) {
136137
return new DataResponse(['message' => 'No valid folder found'], Http::STATUS_BAD_REQUEST);
138+
} catch (StorageNotAvailableException $e) {
139+
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
137140
}
138141
}
139142

@@ -167,6 +170,8 @@ public function publicFolder(string $shareToken, string $path = '/'): DataRespon
167170
return new DataResponse(['message' => 'No valid folder found'], Http::STATUS_BAD_REQUEST);
168171
} catch (ShareNotFound $e) {
169172
return new DataResponse(['message' => 'No valid folder found'], Http::STATUS_BAD_REQUEST);
173+
} catch (StorageNotAvailableException $e) {
174+
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
170175
}
171176
}
172177

lib/DAV/WorkspacePlugin.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use OCA\Text\AppInfo\Application;
3232
use OCA\Text\Service\WorkspaceService;
3333
use OCP\Files\IRootFolder;
34+
use OCP\Files\StorageNotAvailableException;
3435
use OCP\IConfig;
3536
use Sabre\DAV\INode;
3637
use Sabre\DAV\PropFind;
@@ -98,9 +99,13 @@ public function propFind(PropFind $propFind, INode $node) {
9899
$nodes = $this->rootFolder->getUserFolder($this->userId)->getById($node->getId());
99100
if (count($nodes) > 0) {
100101
/** @var File $file */
101-
$file = $this->workspaceService->getFile($nodes[0]);
102-
if ($file instanceof File) {
103-
return $file->getContent();
102+
try {
103+
$file = $this->workspaceService->getFile($nodes[0]);
104+
if ($file instanceof File) {
105+
return $file->getContent();
106+
}
107+
} catch (StorageNotAvailableException $e) {
108+
// If a storage is not available we can for the propfind response assume that there is no rich workspace present
104109
}
105110
}
106111
return '';

lib/Service/WorkspaceService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use OCP\Files\Folder;
88
use OCP\Files\NotFoundException;
9+
use OCP\Files\StorageNotAvailableException;
910
use OCP\IL10N;
1011

1112
class WorkspaceService {
@@ -25,6 +26,7 @@ public function __construct(IL10N $l10n) {
2526

2627
/**
2728
* @param Folder $folder
29+
* @throws StorageNotAvailableException
2830
* @return \OCP\Files\File
2931
*/
3032
public function getFile(Folder $folder) {

0 commit comments

Comments
 (0)