aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/Cache.php')
-rw-r--r--apps/files_sharing/lib/Cache.php65
1 files changed, 22 insertions, 43 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 3011bc64669..f9042fc0765 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -1,39 +1,20 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christopher Schäpers <kondou@ts.unde.re>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_Sharing;
+use OC\Files\Cache\CacheDependencies;
use OC\Files\Cache\FailedCache;
use OC\Files\Cache\Wrapper\CacheJail;
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OC\Files\Storage\Wrapper\Jail;
use OC\User\DisplayNameCache;
+use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
@@ -47,33 +28,27 @@ use OCP\Share\IShare;
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
*/
class Cache extends CacheJail {
- /** @var SharedStorage */
- private $storage;
- private ICacheEntry $sourceRootInfo;
private bool $rootUnchanged = true;
private ?string $ownerDisplayName = null;
private $numericId;
private DisplayNameCache $displayNameCache;
- private IShare $share;
/**
* @param SharedStorage $storage
*/
public function __construct(
- $storage,
- ICacheEntry $sourceRootInfo,
- DisplayNameCache $displayNameCache,
- IShare $share
+ private $storage,
+ private ICacheEntry $sourceRootInfo,
+ CacheDependencies $dependencies,
+ private IShare $share,
) {
- $this->storage = $storage;
- $this->sourceRootInfo = $sourceRootInfo;
- $this->numericId = $sourceRootInfo->getStorageId();
- $this->displayNameCache = $displayNameCache;
- $this->share = $share;
+ $this->numericId = $this->sourceRootInfo->getStorageId();
+ $this->displayNameCache = $dependencies->getDisplayNameCache();
parent::__construct(
null,
- ''
+ '',
+ $dependencies,
);
}
@@ -89,16 +64,16 @@ class Cache extends CacheJail {
/** @var Jail $currentStorage */
$absoluteRoot = $currentStorage->getJailedPath($absoluteRoot);
}
- $this->root = $absoluteRoot;
+ $this->root = $absoluteRoot ?? '';
}
return $this->root;
}
- protected function getGetUnjailedRoot() {
+ public function getGetUnjailedRoot(): string {
return $this->sourceRootInfo->getPath();
}
- public function getCache() {
+ public function getCache(): ICache {
if (is_null($this->cache)) {
$sourceStorage = $this->storage->getSourceStorage();
if ($sourceStorage) {
@@ -141,7 +116,7 @@ class Cache extends CacheJail {
parent::remove($file);
}
- public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, $targetPath) {
+ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
$this->rootUnchanged = false;
return parent::moveFromCache($sourceCache, $sourcePath, $targetPath);
}
@@ -217,4 +192,8 @@ class Cache extends CacheJail {
return null;
}
}
+
+ public function markRootChanged(): void {
+ $this->rootUnchanged = false;
+ }
}