예제 #1
0
 /**
  * Check whether the given storage is available / valid.
  *
  * Note that this operation can be time consuming depending
  * on whether the remote storage is available or not.
  *
  * @param StorageConfig $storage storage configuration
  */
 protected function updateStorageStatus(StorageConfig &$storage)
 {
     try {
         /** @var AuthMechanism */
         $authMechanism = $storage->getAuthMechanism();
         $authMechanism->manipulateStorageConfig($storage);
         /** @var Backend */
         $backend = $storage->getBackend();
         $backend->manipulateStorageConfig($storage);
         // update status (can be time-consuming)
         $storage->setStatus(\OC_Mount_Config::getBackendStatus($backend->getStorageClass(), $storage->getBackendOptions(), false));
     } catch (InsufficientDataForMeaningfulAnswerException $e) {
         $storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE, $this->l10n->t('Insufficient data: %s', [$e->getMessage()]));
     } catch (StorageNotAvailableException $e) {
         $storage->setStatus(\OC_Mount_Config::STATUS_ERROR, $e->getMessage());
     } catch (\Exception $e) {
         // FIXME: convert storage exceptions to StorageNotAvailableException
         $storage->setStatus(\OC_Mount_Config::STATUS_ERROR, get_class($e) . ': ' . $e->getMessage());
     }
 }
예제 #2
0
 private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output)
 {
     try {
         try {
             $this->manipulateStorageConfig($storage);
         } catch (InsufficientDataForMeaningfulAnswerException $e) {
             if (count($configInput) === 0) {
                 // extra config options might solve the error
                 throw $e;
             }
         }
         foreach ($configInput as $configOption) {
             if (!strpos($configOption, '=')) {
                 $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
                 return;
             }
             list($key, $value) = explode('=', $configOption, 2);
             $storage->setBackendOption($key, $value);
         }
         /** @var Backend */
         $backend = $storage->getBackend();
         // update status (can be time-consuming)
         $storage->setStatus(\OC_Mount_Config::getBackendStatus($backend->getStorageClass(), $storage->getBackendOptions(), false));
     } catch (InsufficientDataForMeaningfulAnswerException $e) {
         $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
         $storage->setStatus($status, $e->getMessage());
     } catch (StorageNotAvailableException $e) {
         $storage->setStatus($e->getCode(), $e->getMessage());
     } catch (\Exception $e) {
         // FIXME: convert storage exceptions to StorageNotAvailableException
         $storage->setStatus(StorageNotAvailableException::STATUS_ERROR, get_class($e) . ': ' . $e->getMessage());
     }
 }
예제 #3
0
 /**
  * Check whether the given storage is available / valid.
  *
  * Note that this operation can be time consuming depending
  * on whether the remote storage is available or not.
  *
  * @param StorageConfig $storage storage configuration
  */
 protected function updateStorageStatus(StorageConfig &$storage)
 {
     // update status (can be time-consuming)
     $storage->setStatus(\OC_Mount_Config::getBackendStatus($storage->getBackendClass(), $storage->getBackendOptions(), false));
 }
예제 #4
0
 /**
  * Check whether the given storage is available / valid.
  *
  * Note that this operation can be time consuming depending
  * on whether the remote storage is available or not.
  *
  * @param StorageConfig $storage storage configuration
  */
 protected function updateStorageStatus(StorageConfig &$storage)
 {
     try {
         /** @var AuthMechanism */
         $authMechanism = $storage->getAuthMechanism();
         $authMechanism->manipulateStorageConfig($storage);
         /** @var Backend */
         $backend = $storage->getBackend();
         $backend->manipulateStorageConfig($storage);
         // update status (can be time-consuming)
         $storage->setStatus(\OC_Mount_Config::getBackendStatus($backend->getStorageClass(), $storage->getBackendOptions(), false));
     } catch (InsufficientDataForMeaningfulAnswerException $e) {
         $storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE);
     } catch (StorageNotAvailableException $e) {
         $storage->setStatus(\OC_Mount_Config::STATUS_ERROR);
     }
 }