Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-08-04 10:41:19 +0300
committerGitHub <noreply@github.com>2022-08-04 10:41:19 +0300
commitf421c7a69efbad6d3ae04bd9558f41b0da0ceec7 (patch)
tree0140d2960b541201f277a0b1c466d6d3032242cc
parent392b08d7611e05a75aa97934ef8ba23a7b8d1f92 (diff)
parent8367b99c59d4ef92d597ad963dd64100892b885c (diff)
Merge pull request #32852 from nextcloud/revert-revert-federation-performance-issues
Revert "Revert "Remove inefficient fed share scanner""
-rw-r--r--apps/files_sharing/lib/External/Scanner.php71
-rw-r--r--apps/files_sharing/tests/External/ScannerTest.php12
2 files changed, 3 insertions, 80 deletions
diff --git a/apps/files_sharing/lib/External/Scanner.php b/apps/files_sharing/lib/External/Scanner.php
index cfde56103da..e3336c69a05 100644
--- a/apps/files_sharing/lib/External/Scanner.php
+++ b/apps/files_sharing/lib/External/Scanner.php
@@ -29,27 +29,14 @@ use OC\ForbiddenException;
use OCP\Files\NotFoundException;
use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
-use OCP\Http\Client\LocalServerException;
-use Psr\Log\LoggerInterface;
class Scanner extends \OC\Files\Cache\Scanner {
/** @var \OCA\Files_Sharing\External\Storage */
protected $storage;
- /** {@inheritDoc} */
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
- try {
- if (!$this->storage->remoteIsOwnCloud()) {
- return parent::scan($path, $recursive, $reuse, $lock);
- }
- } catch (LocalServerException $e) {
- // Scanner doesn't have dependency injection
- \OC::$server->get(LoggerInterface::class)
- ->warning('Trying to scan files inside invalid external storage: ' . $this->storage->getRemote() . ' for mountpoint ' . $this->storage->getMountPoint() . ' and id ' . $this->storage->getId());
- return;
- }
-
- $this->scanAll();
+ // Disable locking for federated shares
+ parent::scan($path, $recursive, $reuse, false);
}
/**
@@ -67,7 +54,7 @@ class Scanner extends \OC\Files\Cache\Scanner {
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
try {
- return parent::scanFile($file, $reuseExisting);
+ return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock, $data);
} catch (ForbiddenException $e) {
$this->storage->checkStorageAvailability();
} catch (NotFoundException $e) {
@@ -81,56 +68,4 @@ class Scanner extends \OC\Files\Cache\Scanner {
$this->storage->checkStorageAvailability();
}
}
-
- /**
- * Checks the remote share for changes.
- * If changes are available, scan them and update
- * the cache.
- * @throws NotFoundException
- * @throws StorageInvalidException
- * @throws \Exception
- */
- public function scanAll() {
- try {
- $data = $this->storage->getShareInfo();
- } catch (\Exception $e) {
- $this->storage->checkStorageAvailability();
- throw new \Exception(
- 'Error while scanning remote share: "' .
- $this->storage->getRemote() . '" ' .
- $e->getMessage()
- );
- }
- if ($data['status'] === 'success') {
- $this->addResult($data['data'], '');
- } else {
- throw new \Exception(
- 'Error while scanning remote share: "' .
- $this->storage->getRemote() . '"'
- );
- }
- }
-
- /**
- * @param array $data
- * @param string $path
- */
- private function addResult($data, $path) {
- $id = $this->cache->put($path, $data);
- if (isset($data['children'])) {
- $children = [];
- foreach ($data['children'] as $child) {
- $children[$child['name']] = true;
- $this->addResult($child, ltrim($path . '/' . $child['name'], '/'));
- }
-
- $existingCache = $this->cache->getFolderContentsById($id);
- foreach ($existingCache as $existingChild) {
- // if an existing child is not in the new data, remove it
- if (!isset($children[$existingChild['name']])) {
- $this->cache->remove(ltrim($path . '/' . $existingChild['name'], '/'));
- }
- }
- }
- }
}
diff --git a/apps/files_sharing/tests/External/ScannerTest.php b/apps/files_sharing/tests/External/ScannerTest.php
index 57696a697eb..2d2486737dc 100644
--- a/apps/files_sharing/tests/External/ScannerTest.php
+++ b/apps/files_sharing/tests/External/ScannerTest.php
@@ -50,18 +50,6 @@ class ScannerTest extends TestCase {
$this->scanner = new Scanner($this->storage);
}
- public function testScanAll() {
- $this->storage->expects($this->any())
- ->method('getShareInfo')
- ->willReturn(['status' => 'success', 'data' => []]);
-
- // FIXME add real tests, we are currently only checking for
- // Declaration of OCA\Files_Sharing\External\Scanner::*() should be
- // compatible with OC\Files\Cache\Scanner::*()
- $this->scanner->scanAll();
- $this->addToAssertionCount(1);
- }
-
public function testScan() {
$this->storage->expects($this->any())
->method('getShareInfo')