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
*
* @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);
+ }
+ }
}