]> source.dussan.org Git - nextcloud-server.git/commitdiff
Handle external share with invalid host 30353/head
authorCarl Schwan <carl@carlschwan.eu>
Mon, 20 Dec 2021 14:20:52 +0000 (15:20 +0100)
committerCarl Schwan <carl@carlschwan.eu>
Mon, 20 Dec 2021 14:28:14 +0000 (15:28 +0100)
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 <carl@carlschwan.eu>
apps/files_sharing/lib/External/Storage.php

index 7d9e8f31c98c326de91af9cc55dbfb9fa8572565..67df60cb55f659c6ae5614157b13326376739a24 100644 (file)
@@ -44,6 +44,7 @@ use OCP\Files\NotFoundException;
 use OCP\Files\Storage\IDisableEncryptionStorage;
 use OCP\Files\StorageInvalidException;
 use OCP\Files\StorageNotAvailableException;
+use OCP\Http\Client\LocalServerException;
 
 class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
        /** @var ICloudId */
@@ -314,9 +315,16 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
                $token = $this->getToken();
                $password = $this->getPassword();
 
-               // If remote is not an ownCloud do not try to get any share info
-               if (!$this->remoteIsOwnCloud()) {
-                       return ['status' => 'unsupported'];
+               try {
+                       // If remote is not an ownCloud do not try to get any share info
+                       if (!$this->remoteIsOwnCloud()) {
+                               return ['status' => 'unsupported'];
+                       }
+               } catch (LocalServerException $e) {
+                       // throw this to be on the safe side: the share will still be visible
+                       // in the UI in case the failure is intermittent, and the user will
+                       // be able to decide whether to remove it if it's really gone
+                       throw new StorageNotAvailableException();
                }
 
                $url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token;