Example #1
0
 /**
  * attach listeners to the scanner
  *
  * @param \OC\Files\Mount\MountPoint $mount
  */
 protected function attachListener($mount)
 {
     $scanner = $mount->getStorage()->getScanner();
     $emitter = $this;
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'scanFile', function ($path) use($mount, $emitter) {
         $emitter->emit('\\OC\\Files\\Utils\\Scanner', 'scanFile', array($mount->getMountPoint() . $path));
     });
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'scanFolder', function ($path) use($mount, $emitter) {
         $emitter->emit('\\OC\\Files\\Utils\\Scanner', 'scanFolder', array($mount->getMountPoint() . $path));
     });
     // propagate etag and mtimes when files are changed or removed
     $propagator = $this->propagator;
     $propagatorListener = function ($path) use($mount, $propagator) {
         $fullPath = Filesystem::normalizePath($mount->getMountPoint() . $path);
         $propagator->addChange($fullPath);
     };
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'addToCache', $propagatorListener);
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'removeFromCache', $propagatorListener);
 }
Example #2
0
 public function testSimpleWrapper()
 {
     $instance = new \OC\Files\Storage\StorageFactory();
     $mount = new MountPoint('\\OC\\Files\\Storage\\Temporary', '/foo', [[]], $instance);
     $instance->addStorageWrapper('dummy', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
         $this->assertInstanceOf('\\OC\\Files\\Storage\\Temporary', $storage);
         $this->assertEquals('/foo/', $mount->getMountPoint());
         $this->assertEquals('/foo/', $mountPoint);
         return new DummyWrapper(['storage' => $storage]);
     });
     $wrapped = $mount->getStorage();
     $this->assertInstanceOf('\\Test\\Files\\Storage\\DummyWrapper', $wrapped);
 }
Example #3
0
 /**
  * attach listeners to the scanner
  *
  * @param \OC\Files\Mount\MountPoint $mount
  */
 protected function attachListener($mount)
 {
     $scanner = $mount->getStorage()->getScanner();
     $emitter = $this;
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'scanFile', function ($path) use($mount, $emitter) {
         $emitter->emit('\\OC\\Files\\Utils\\Scanner', 'scanFile', array($mount->getMountPoint() . $path));
     });
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'scanFolder', function ($path) use($mount, $emitter) {
         $emitter->emit('\\OC\\Files\\Utils\\Scanner', 'scanFolder', array($mount->getMountPoint() . $path));
     });
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'postScanFile', function ($path) use($mount, $emitter) {
         $emitter->emit('\\OC\\Files\\Utils\\Scanner', 'postScanFile', array($mount->getMountPoint() . $path));
     });
     $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'postScanFolder', function ($path) use($mount, $emitter) {
         $emitter->emit('\\OC\\Files\\Utils\\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path));
     });
 }
Example #4
0
 /**
  * @param MountPoint $mount
  */
 public function addMount(MountPoint $mount)
 {
     $this->mounts[$mount->getMountPoint()] = $mount;
 }