2015-01-14 06:35:24 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2015-01-14 06:35:24 -05:00
|
|
|
/**
|
2024-06-06 13:48:28 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-01-14 06:35:24 -05:00
|
|
|
*/
|
2021-11-16 12:10:09 -05:00
|
|
|
|
2016-05-02 09:16:20 -04:00
|
|
|
namespace OCA\Files_Sharing;
|
2015-01-14 06:35:24 -05:00
|
|
|
|
2023-04-12 12:08:14 -04:00
|
|
|
use OC\Files\ObjectStore\ObjectStoreScanner;
|
2024-10-18 06:04:22 -04:00
|
|
|
use OC\Files\Storage\Storage;
|
2016-01-11 10:09:30 -05:00
|
|
|
|
2015-01-14 06:35:24 -05:00
|
|
|
/**
|
|
|
|
|
* Scanner for SharedStorage
|
|
|
|
|
*/
|
2016-05-02 09:16:20 -04:00
|
|
|
class Scanner extends \OC\Files\Cache\Scanner {
|
2016-12-14 08:35:45 -05:00
|
|
|
/**
|
2024-10-10 06:40:31 -04:00
|
|
|
* @var SharedStorage $storage
|
2016-12-14 08:35:45 -05:00
|
|
|
*/
|
|
|
|
|
protected $storage;
|
|
|
|
|
|
2016-01-11 10:09:30 -05:00
|
|
|
private $sourceScanner;
|
2015-01-14 06:35:24 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns metadata from the shared storage, but
|
|
|
|
|
* with permissions from the source storage.
|
|
|
|
|
*
|
|
|
|
|
* @param string $path path of the file for which to retrieve metadata
|
|
|
|
|
*
|
2021-02-15 11:52:11 -05:00
|
|
|
* @return array|null an array of metadata of the file
|
2015-01-14 06:35:24 -05:00
|
|
|
*/
|
2016-01-11 10:09:30 -05:00
|
|
|
public function getData($path) {
|
2015-01-14 06:35:24 -05:00
|
|
|
$data = parent::getData($path);
|
2016-04-15 03:01:10 -04:00
|
|
|
if ($data === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2017-04-12 08:55:47 -04:00
|
|
|
$internalPath = $this->storage->getUnjailedPath($path);
|
2016-12-14 08:35:45 -05:00
|
|
|
$data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath);
|
2015-01-14 06:35:24 -05:00
|
|
|
return $data;
|
|
|
|
|
}
|
2016-01-11 10:09:30 -05:00
|
|
|
|
|
|
|
|
private function getSourceScanner() {
|
|
|
|
|
if ($this->sourceScanner) {
|
|
|
|
|
return $this->sourceScanner;
|
|
|
|
|
}
|
2016-06-01 08:29:31 -04:00
|
|
|
if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
|
2024-10-18 06:04:22 -04:00
|
|
|
/** @var Storage $storage */
|
2021-01-12 04:15:48 -05:00
|
|
|
[$storage] = $this->storage->resolvePath('');
|
2016-01-11 10:09:30 -05:00
|
|
|
$this->sourceScanner = $storage->getScanner();
|
|
|
|
|
return $this->sourceScanner;
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 12:47:20 -04:00
|
|
|
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
|
2016-01-11 10:09:30 -05:00
|
|
|
$sourceScanner = $this->getSourceScanner();
|
2023-04-12 12:08:14 -04:00
|
|
|
if ($sourceScanner instanceof ObjectStoreScanner) {
|
|
|
|
|
// ObjectStoreScanner doesn't scan
|
2025-01-26 08:56:17 -05:00
|
|
|
return null;
|
2016-01-11 10:09:30 -05:00
|
|
|
} else {
|
|
|
|
|
return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-14 06:35:24 -05:00
|
|
|
}
|