Move away from private static deprecated functio
This commit is contained in:
parent
73a3086945
commit
be8d0a08ec
|
@ -56,20 +56,25 @@ $externalManager = new \OCA\Files_Sharing\External\Manager(
|
|||
);
|
||||
|
||||
// check for ssl cert
|
||||
if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
|
||||
if (substr($remote, 0, 5) === 'https') {
|
||||
try {
|
||||
\OC::$server->getHTTPClientService()->newClient()->get($remote)->getBody();
|
||||
} catch (\Exception $e) {
|
||||
\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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
$mount = $externalManager->addShare($remote, $token, $password, $name, $owner, true);
|
||||
|
||||
/**
|
||||
* @var \OCA\Files_Sharing\External\Storage $storage
|
||||
*/
|
||||
$storage = $mount->getStorage();
|
||||
try {
|
||||
$storage = $mount->getStorage();
|
||||
try {
|
||||
// check if storage exists
|
||||
$storage->checkStorageAvailability();
|
||||
} catch (\OCP\Files\StorageInvalidException $e) {
|
||||
} catch (\OCP\Files\StorageInvalidException $e) {
|
||||
// note: checkStorageAvailability will already remove the invalid share
|
||||
\OCP\Util::writeLog(
|
||||
'files_sharing',
|
||||
|
@ -84,7 +89,7 @@ if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
|
|||
)
|
||||
);
|
||||
exit();
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
\OCP\Util::writeLog(
|
||||
'files_sharing',
|
||||
'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
|
||||
|
@ -93,9 +98,9 @@ if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
|
|||
$externalManager->removeShare($mount->getMountPoint());
|
||||
\OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
|
||||
exit();
|
||||
}
|
||||
$result = $storage->file_exists('');
|
||||
if ($result) {
|
||||
}
|
||||
$result = $storage->file_exists('');
|
||||
if ($result) {
|
||||
try {
|
||||
$storage->getScanner()->scanAll();
|
||||
\OCP\JSON::success();
|
||||
|
@ -114,7 +119,7 @@ if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
|
|||
);
|
||||
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
$externalManager->removeShare($mount->getMountPoint());
|
||||
\OCP\Util::writeLog(
|
||||
'files_sharing',
|
||||
|
@ -122,5 +127,5 @@ if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
|
|||
\OCP\Util::DEBUG
|
||||
);
|
||||
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue