コード例 #1
0
ファイル: configadapter.php プロジェクト: Juraganet/core
 /**
  * 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]);
         }
         $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;
 }
コード例 #2
0
ファイル: configadapter.php プロジェクト: gvde/core
 /**
  * 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;
 }