Example #1
0
 /**
  * Get all mountpoints applicable for the user
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $loader
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $loader)
 {
     $mounts = [];
     $this->userStoragesService->setUser($user);
     $this->userGlobalStoragesService->setUser($user);
     foreach ($this->userGlobalStoragesService->getAllStorages() as $storage) {
         try {
             $this->prepareStorageConfig($storage, $user);
             $impl = $this->constructStorage($storage);
         } catch (\Exception $e) {
             // propagate exception into filesystem
             $impl = new FailedStorage(['exception' => $e]);
         }
         $mount = new MountPoint($impl, '/' . $user->getUID() . '/files' . $storage->getMountPoint(), null, $loader, $storage->getMountOptions());
         $mounts[$storage->getMountPoint()] = $mount;
     }
     foreach ($this->userStoragesService->getAllStorages() as $storage) {
         try {
             $this->prepareStorageConfig($storage, $user);
             $impl = $this->constructStorage($storage);
         } catch (\Exception $e) {
             // propagate exception into filesystem
             $impl = new FailedStorage(['exception' => $e]);
         }
         $mount = new PersonalMount($this->userStoragesService, $storage->getId(), $impl, '/' . $user->getUID() . '/files' . $storage->getMountPoint(), null, $loader, $storage->getMountOptions());
         $mounts[$storage->getMountPoint()] = $mount;
     }
     $this->userStoragesService->resetUser();
     $this->userGlobalStoragesService->resetUser();
     return $mounts;
 }
Example #2
0
 /**
  * Get all mountpoints applicable for the user
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $loader
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $loader)
 {
     $this->migrator->migrateUser($user);
     $mounts = [];
     $this->userStoragesService->setUser($user);
     $this->userGlobalStoragesService->setUser($user);
     foreach ($this->userGlobalStoragesService->getUniqueStorages() as $storage) {
         try {
             $this->prepareStorageConfig($storage, $user);
             $impl = $this->constructStorage($storage);
         } catch (\Exception $e) {
             // propagate exception into filesystem
             $impl = new FailedStorage(['exception' => $e]);
         }
         try {
             $availability = $impl->getAvailability();
             if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
                 $impl = new FailedStorage(['exception' => new StorageNotAvailableException('Storage with mount id ' . $storage->getId() . ' is not available')]);
             }
         } catch (\Exception $e) {
             // propagate exception into filesystem
             $impl = new FailedStorage(['exception' => $e]);
         }
         $mount = new MountPoint($impl, '/' . $user->getUID() . '/files' . $storage->getMountPoint(), null, $loader, $storage->getMountOptions());
         $mounts[$storage->getMountPoint()] = $mount;
     }
     foreach ($this->userStoragesService->getStorages() as $storage) {
         try {
             $this->prepareStorageConfig($storage, $user);
             $impl = $this->constructStorage($storage);
         } catch (\Exception $e) {
             // propagate exception into filesystem
             $impl = new FailedStorage(['exception' => $e]);
         }
         $mount = new PersonalMount($this->userStoragesService, $storage->getId(), $impl, '/' . $user->getUID() . '/files' . $storage->getMountPoint(), null, $loader, $storage->getMountOptions());
         $mounts[$storage->getMountPoint()] = $mount;
     }
     $this->userStoragesService->resetUser();
     $this->userGlobalStoragesService->resetUser();
     return $mounts;
 }
Example #3
0
 /**
  * Remove the mount points
  *
  * @return bool
  */
 public function removeMount()
 {
     $this->storagesService->removeStorage($this->storageId);
     return true;
 }