Skip to content

Commit 234d6df

Browse files
committed
Handle external share with invalid host
remoteIsOwnCloud might throw an exception when the host is localhost. Handle this case instead of aborting completely. The behavior is the same as that is done 10 lines under it Signed-off-by: Carl Schwan <[email protected]>
1 parent 4b36f9d commit 234d6df

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

apps/files_sharing/lib/External/Storage.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OCP\Files\Storage\IDisableEncryptionStorage;
4545
use OCP\Files\StorageInvalidException;
4646
use OCP\Files\StorageNotAvailableException;
47+
use OCP\Http\Client\LocalServerException;
4748

4849
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
4950
/** @var ICloudId */
@@ -314,9 +315,16 @@ public function getShareInfo() {
314315
$token = $this->getToken();
315316
$password = $this->getPassword();
316317

317-
// If remote is not an ownCloud do not try to get any share info
318-
if (!$this->remoteIsOwnCloud()) {
319-
return ['status' => 'unsupported'];
318+
try {
319+
// If remote is not an ownCloud do not try to get any share info
320+
if (!$this->remoteIsOwnCloud()) {
321+
return ['status' => 'unsupported'];
322+
}
323+
} catch (LocalServerException $e) {
324+
// throw this to be on the safe side: the share will still be visible
325+
// in the UI in case the failure is intermittent, and the user will
326+
// be able to decide whether to remove it if it's really gone
327+
throw new StorageNotAvailableException($e);
320328
}
321329

322330
$url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token;

0 commit comments

Comments
 (0)