Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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;
     }
 }