handle noopscanner in shared scanner
This commit is contained in:
parent
ddbbe1742f
commit
30d6222e64
|
@ -22,10 +22,14 @@
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue