Beispiel #1
0
 /**
  * Check whether this storage is permanently or temporarily
  * unavailable
  *
  * @throws \OCP\Files\StorageNotAvailableException
  * @throws \OCP\Files\StorageInvalidException
  */
 public function checkStorageAvailability()
 {
     // see if we can find out why the share is unavailable
     try {
         $this->getShareInfo();
     } catch (NotFoundException $e) {
         // a 404 can either mean that the share no longer exists or there is no ownCloud on the remote
         if ($this->testRemote()) {
             // valid ownCloud instance means that the public share no longer exists
             // since this is permanent (re-sharing the file will create a new token)
             // we remove the invalid storage
             $this->manager->removeShare($this->mountPoint);
             $this->manager->getMountManager()->removeMount($this->mountPoint);
             throw new StorageInvalidException();
         } else {
             // ownCloud instance is gone, likely to be a temporary server configuration error
             throw new StorageNotAvailableException();
         }
     } catch (ForbiddenException $e) {
         // auth error, remove share for now (provide a dialog in the future)
         $this->manager->removeShare($this->mountPoint);
         $this->manager->getMountManager()->removeMount($this->mountPoint);
         throw new StorageInvalidException();
     } catch (\GuzzleHttp\Exception\ConnectException $e) {
         throw new StorageNotAvailableException();
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         throw new StorageNotAvailableException();
     } catch (\Exception $e) {
         throw $e;
     }
 }
Beispiel #2
0
 /**
  * check if a file or folder has been updated since $time
  *
  * @param string $path
  * @param int $time
  * @throws \OCP\Files\StorageNotAvailableException
  * @throws \OCP\Files\StorageInvalidException
  * @return bool
  */
 public function hasUpdated($path, $time)
 {
     // since for owncloud webdav servers we can rely on etag propagation we only need to check the root of the storage
     // because of that we only do one check for the entire storage per request
     if ($this->updateChecked) {
         return false;
     }
     $this->updateChecked = true;
     try {
         return parent::hasUpdated('', $time);
     } catch (StorageNotAvailableException $e) {
         // see if we can find out why the share is unavailable\
         try {
             $this->getShareInfo();
         } catch (NotFoundException $shareException) {
             // a 404 can either mean that the share no longer exists or there is no ownCloud on the remote
             if ($this->testRemote()) {
                 // valid ownCloud instance means that the public share no longer exists
                 // since this is permanent (re-sharing the file will create a new token)
                 // we remove the invalid storage
                 $this->manager->removeShare($this->mountPoint);
                 $this->manager->getMountManager()->removeMount($this->mountPoint);
                 throw new StorageInvalidException();
             } else {
                 // ownCloud instance is gone, likely to be a temporary server configuration error
                 throw $e;
             }
         } catch (\Exception $shareException) {
             // todo, maybe handle 403 better and ask the user for a new password
             throw $e;
         }
         throw $e;
     }
 }
Beispiel #3
0
 /**
  * Remove the mount points
  *
  * @return mixed
  * @return bool
  */
 public function removeMount()
 {
     return $this->manager->removeShare($this->mountPoint);
 }
Beispiel #4
0
 /**
  * Unshare a remote share
  *
  * @param array $params contains the shareID 'id' which should be unshared
  * @return \OC_OCS_Result
  */
 public static function unshare($params)
 {
     $externalManager = new Manager(\OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getNotificationManager(), \OC_User::getUser());
     $shareInfo = $externalManager->getShare($params['id']);
     if ($shareInfo === false) {
         return new \OC_OCS_Result(null, 404, 'Share does not exist');
     }
     $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint'];
     if ($externalManager->removeShare($mountPoint) === true) {
         return new \OC_OCS_Result(null);
     } else {
         return new \OC_OCS_Result(null, 403, 'Could not unshare');
     }
 }