]> source.dussan.org Git - nextcloud-server.git/commitdiff
handle noopscanner in shared scanner
authorRobin Appelman <icewind@owncloud.com>
Mon, 11 Jan 2016 15:09:30 +0000 (16:09 +0100)
committerRobin Appelman <icewind@owncloud.com>
Fri, 15 Jan 2016 14:37:31 +0000 (15:37 +0100)
apps/files_sharing/lib/scanner.php
apps/files_sharing/lib/sharedstorage.php

index bd6a28a49348980971ca9d65cac5032fa0d34b2d..e9cc40ae42c0833fbc4480b812d4b1cb7d363421 100644 (file)
 
 namespace OC\Files\Cache;
 
+use OC\Files\ObjectStore\NoopScanner;
+use OC\Files\Storage\Shared;
+
 /**
  * Scanner for SharedStorage
  */
 class SharedScanner extends Scanner {
+       private $sourceScanner;
 
        /**
         * Returns metadata from the shared storage, but
@@ -35,12 +39,35 @@ class SharedScanner extends Scanner {
         *
         * @return array an array of metadata of the file
         */
-       protected function getData($path){
+       public function getData($path) {
                $data = parent::getData($path);
                $sourcePath = $this->storage->getSourcePath($path);
                list($sourceStorage, $internalPath) = \OC\Files\Filesystem::resolvePath($sourcePath);
                $data['permissions'] = $sourceStorage->getPermissions($internalPath);
                return $data;
        }
+
+       private function getSourceScanner() {
+               if ($this->sourceScanner) {
+                       return $this->sourceScanner;
+               }
+               if ($this->storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
+                       /** @var \OC\Files\Storage\Storage $storage */
+                       list($storage) = $this->storage->resolvePath('');
+                       $this->sourceScanner = $storage->getScanner();
+                       return $this->sourceScanner;
+               } else {
+                       return null;
+               }
+       }
+
+       public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
+               $sourceScanner = $this->getSourceScanner();
+               if ($sourceScanner instanceof NoopScanner) {
+                       return [];
+               } else {
+                       return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock);
+               }
+       }
 }
 
index 697856e1de508af0853056e18a8a71a0b91e38a3..542d0e9e48c644d980d0d4b93fff159507d6feda 100644 (file)
@@ -609,7 +609,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
         * @param string $path
         * @return array
         */
-       private function resolvePath($path) {
+       public function resolvePath($path) {
                $source = $this->getSourcePath($path);
                return \OC\Files\Filesystem::resolvePath($source);
        }