handle noopscanner in shared scanner

This commit is contained in:
Robin Appelman 2016-01-11 16:09:30 +01:00
parent ddbbe1742f
commit 30d6222e64
2 changed files with 29 additions and 2 deletions

View File

@ -22,10 +22,14 @@
namespace OC\Files\Cache; namespace OC\Files\Cache;
use OC\Files\ObjectStore\NoopScanner;
use OC\Files\Storage\Shared;
/** /**
* Scanner for SharedStorage * Scanner for SharedStorage
*/ */
class SharedScanner extends Scanner { class SharedScanner extends Scanner {
private $sourceScanner;
/** /**
* Returns metadata from the shared storage, but * Returns metadata from the shared storage, but
@ -35,12 +39,35 @@ class SharedScanner extends Scanner {
* *
* @return array an array of metadata of the file * @return array an array of metadata of the file
*/ */
protected function getData($path){ public function getData($path) {
$data = parent::getData($path); $data = parent::getData($path);
$sourcePath = $this->storage->getSourcePath($path); $sourcePath = $this->storage->getSourcePath($path);
list($sourceStorage, $internalPath) = \OC\Files\Filesystem::resolvePath($sourcePath); list($sourceStorage, $internalPath) = \OC\Files\Filesystem::resolvePath($sourcePath);
$data['permissions'] = $sourceStorage->getPermissions($internalPath); $data['permissions'] = $sourceStorage->getPermissions($internalPath);
return $data; 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);
}
}
} }

View File

@ -609,7 +609,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @param string $path * @param string $path
* @return array * @return array
*/ */
private function resolvePath($path) { public function resolvePath($path) {
$source = $this->getSourcePath($path); $source = $this->getSourcePath($path);
return \OC\Files\Filesystem::resolvePath($source); return \OC\Files\Filesystem::resolvePath($source);
} }