diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-01-28 00:31:37 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-01-28 00:31:37 +0100 |
commit | 87b39e8f03913f6e571c526167c18f0be0021c41 (patch) | |
tree | a190a15c3549c53dcc263ccd41334507d9865caa /apps/files_sharing/ajax | |
parent | 3fa6e0f4dca7f477e93b10287f7de5cc75d39275 (diff) | |
parent | 5376b0b123873269a92d9aa45f6233c48c2720df (diff) | |
download | nextcloud-server-87b39e8f03913f6e571c526167c18f0be0021c41.tar.gz nextcloud-server-87b39e8f03913f6e571c526167c18f0be0021c41.zip |
Merge pull request #13525 from owncloud/s2s-fixscanfileforbrokenstorage
Catch storage exception in scanner for remote shares
Diffstat (limited to 'apps/files_sharing/ajax')
-rw-r--r-- | apps/files_sharing/ajax/external.php | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php index a206cacafa3..30c1f38801e 100644 --- a/apps/files_sharing/ajax/external.php +++ b/apps/files_sharing/ajax/external.php @@ -42,20 +42,70 @@ $name = OCP\Files::buildNotExistingFileName('/', $name); // check for ssl cert if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) { - \OCP\JSON::error(array('data' => array('message' => $l->t("Invalid or untrusted SSL certificate")))); + \OCP\JSON::error(array('data' => array('message' => $l->t('Invalid or untrusted SSL certificate')))); exit; } else { $mount = $externalManager->addShare($remote, $token, $password, $name, $owner, true); + /** * @var \OCA\Files_Sharing\External\Storage $storage */ $storage = $mount->getStorage(); + try { + // check if storage exists + $storage->checkStorageAvailability(); + } catch (\OCP\Files\StorageInvalidException $e) { + // note: checkStorageAvailability will already remove the invalid share + \OCP\Util::writeLog( + 'files_sharing', + 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), + \OCP\Util::DEBUG + ); + \OCP\JSON::error( + array( + 'data' => array( + 'message' => $l->t('Could not authenticate to remote share, password might be wrong') + ) + ) + ); + exit(); + } catch (\Exception $e) { + \OCP\Util::writeLog( + 'files_sharing', + 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), + \OCP\Util::DEBUG + ); + $externalManager->removeShare($mount->getMountPoint()); + \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid')))); + exit(); + } $result = $storage->file_exists(''); if ($result) { - $storage->getScanner()->scanAll(); - \OCP\JSON::success(); + try { + $storage->getScanner()->scanAll(); + \OCP\JSON::success(); + } catch (\OCP\Files\StorageInvalidException $e) { + \OCP\Util::writeLog( + 'files_sharing', + 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), + \OCP\Util::DEBUG + ); + \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid')))); + } catch (\Exception $e) { + \OCP\Util::writeLog( + 'files_sharing', + 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), + \OCP\Util::DEBUG + ); + \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share')))); + } } else { $externalManager->removeShare($mount->getMountPoint()); - \OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't add remote share")))); + \OCP\Util::writeLog( + 'files_sharing', + 'Couldn\'t add remote share', + \OCP\Util::DEBUG + ); + \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share')))); } } |