Exemple #1
0
 /**
  * Hook that mounts the given user's visible mount points
  *
  * @param array $data
  */
 public static function initMountPointsHook($data)
 {
     if ($data['user']) {
         $user = \OC::$server->getUserManager()->get($data['user']);
         if (!$user) {
             \OC::$server->getLogger()->warning('Cannot init external mount points for non-existant user "' . $data['user'] . '".', ['app' => 'files_external']);
             return;
         }
         $userView = new \OC\Files\View('/' . $user->getUID() . '/files');
         $changePropagator = new \OC\Files\Cache\ChangePropagator($userView);
         $etagPropagator = new \OCA\Files_External\EtagPropagator($user, $changePropagator, \OC::$server->getConfig());
         $etagPropagator->propagateDirtyMountPoints();
         \OCP\Util::connectHook(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create_mount, $etagPropagator, 'updateHook');
         \OCP\Util::connectHook(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_delete_mount, $etagPropagator, 'updateHook');
     }
 }
Exemple #2
0
 /**
  * Hook that mounts the given user's visible mount points
  * @param array $data
  */
 public static function initMountPointsHook($data)
 {
     $mountPoints = self::getAbsoluteMountPoints($data['user']);
     $loader = \OC\Files\Filesystem::getLoader();
     $manager = \OC\Files\Filesystem::getMountManager();
     foreach ($mountPoints as $mountPoint => $options) {
         if (isset($options['options']['objectstore'])) {
             $objectClass = $options['options']['objectstore']['class'];
             $options['options']['objectstore'] = new $objectClass($options['options']['objectstore']);
         }
         if (isset($options['personal']) && $options['personal']) {
             $mount = new \OCA\Files_External\PersonalMount($options['class'], $mountPoint, $options['options'], $loader);
         } else {
             $mount = new \OC\Files\Mount\Mount($options['class'], $mountPoint, $options['options'], $loader);
         }
         $manager->addMount($mount);
     }
     if ($data['user']) {
         $user = \OC::$server->getUserManager()->get($data['user']);
         $userView = new \OC\Files\View('/' . $user->getUID() . '/files');
         $changePropagator = new \OC\Files\Cache\ChangePropagator($userView);
         $etagPropagator = new \OCA\Files_External\EtagPropagator($user, $changePropagator, \OC::$server->getConfig());
         $etagPropagator->propagateDirtyMountPoints();
         \OCP\Util::connectHook(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create_mount, $etagPropagator, 'updateHook');
         \OCP\Util::connectHook(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_delete_mount, $etagPropagator, 'updateHook');
     }
 }
 public function testGlobalMountMultipleDirtyMountPoints()
 {
     $time = time();
     $user = $this->getUser();
     $config = $this->getConfig();
     $changePropagator = $this->getChangePropagator();
     $propagator = new \OCA\Files_External\EtagPropagator($user, $changePropagator, $config);
     $config->setAppValue('files_external', '/test', $time - 10);
     $config->setAppValue('files_external', '/foo', $time - 50);
     $config->setAppValue('files_external', '/bar', $time - 70);
     $config->setUserValue($user->getUID(), 'files_external', '/foo', $time - 70);
     $config->setUserValue($user->getUID(), 'files_external', '/bar', $time - 70);
     $changePropagator->expects($this->exactly(2))->method('addChange');
     $changePropagator->expects($this->once())->method('propagateChanges')->with($time);
     $propagator->propagateDirtyMountPoints($time);
     $this->assertEquals($time, $config->getUserValue($user->getUID(), 'files_external', '/test'));
     $this->assertEquals($time, $config->getUserValue($user->getUID(), 'files_external', '/foo'));
     $this->assertEquals($time - 70, $config->getUserValue($user->getUID(), 'files_external', '/bar'));
 }