aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Files/Cache/ICache.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Files/Cache/ICache.php')
-rw-r--r--lib/public/Files/Cache/ICache.php91
1 files changed, 64 insertions, 27 deletions
diff --git a/lib/public/Files/Cache/ICache.php b/lib/public/Files/Cache/ICache.php
index 95ca29c2aa8..cd610b15545 100644
--- a/lib/public/Files/Cache/ICache.php
+++ b/lib/public/Files/Cache/ICache.php
@@ -1,46 +1,46 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Robin Appelman <robin@icewind.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 OCP\Files\Cache;
+use OCP\Files\Search\ISearchOperator;
use OCP\Files\Search\ISearchQuery;
/**
* Metadata cache for a storage
*
- * The cache stores the metadata for all files and folders in a storage and is kept up to date trough the following mechanisms:
+ * The cache stores the metadata for all files and folders in a storage and is kept up to date through the following mechanisms:
*
* - Scanner: scans the storage and updates the cache where needed
- * - Watcher: checks for changes made to the filesystem outside of the ownCloud instance and rescans files and folder when a change is detected
- * - Updater: listens to changes made to the filesystem inside of the ownCloud instance and updates the cache where needed
+ * - Watcher: checks for changes made to the filesystem outside of the Nextcloud instance and rescans files and folder when a change is detected
+ * - Updater: listens to changes made to the filesystem inside of the Nextcloud instance and updates the cache where needed
* - ChangePropagator: updates the mtime and etags of parent folders whenever a change to the cache is made to the cache by the updater
*
* @since 9.0.0
*/
interface ICache {
+ /**
+ * @since 9.0.0
+ */
public const NOT_FOUND = 0;
+
+ /**
+ * @since 9.0.0
+ */
public const PARTIAL = 1; //only partial data available, file not cached in the database
+
+ /**
+ * @since 9.0.0
+ */
public const SHALLOW = 2; //folder in cache, but not all child files are completely scanned
+
+ /**
+ * @since 9.0.0
+ */
public const COMPLETE = 3;
/**
@@ -119,7 +119,7 @@ interface ICache {
/**
* get the file id for a file
*
- * A file id is a numeric id for a file or folder that's unique within an owncloud instance which stays the same for the lifetime of a file
+ * A file id is a numeric id for a file or folder that's unique within an Nextcloud instance which stays the same for the lifetime of a file
*
* File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing
*
@@ -180,6 +180,17 @@ interface ICache {
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath);
/**
+ * Copy a file or folder in the cache
+ *
+ * @param ICache $sourceCache
+ * @param ICacheEntry $sourceEntry
+ * @param string $targetPath
+ * @return int fileid of copied entry
+ * @since 22.0.0
+ */
+ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int;
+
+ /**
* Get the scan status of a file
*
* - ICache::NOT_FOUND: File is not in the cache
@@ -208,7 +219,7 @@ interface ICache {
* search for files by mimetype
*
* @param string $mimetype either a full mimetype to search ('text/plain') or only the first part of a mimetype ('image')
- * where it will search for all mimetypes in the group ('image/*')
+ * where it will search for all mimetypes in the group ('image/*')
* @return ICacheEntry[] an array of cache entries where the mimetype matches the search
* @since 9.0.0
* @deprecated 9.0.0 due to lack of pagination, not all backends might implement this
@@ -220,7 +231,7 @@ interface ICache {
*
* @param ISearchQuery $query
* @return ICacheEntry[]
- * @throw \InvalidArgumentException if the cache is unable to perform the query
+ * @throws \InvalidArgumentException if the cache is unable to perform the query
* @since 12.0.0
*/
public function searchQuery(ISearchQuery $query);
@@ -232,7 +243,7 @@ interface ICache {
* use the one with the highest id gives the best result with the background scanner, since that is most
* likely the folder where we stopped scanning previously
*
- * @return string|bool the path of the folder or false when no folder matched
+ * @return string|false the path of the folder or false when no folder matched
* @since 9.0.0
*/
public function getIncomplete();
@@ -254,4 +265,30 @@ interface ICache {
* @since 9.0.0
*/
public function normalize($path);
+
+ /**
+ * Get the query expression required to filter files within this storage.
+ *
+ * In the most basic case this is just comparing the storage id
+ * but storage wrappers can add additional expressions to filter down things further
+ *
+ * @return ISearchOperator
+ * @since 22.0.0
+ */
+ public function getQueryFilterForStorage(): ISearchOperator;
+
+ /**
+ * Construct a cache entry from a search result row *if* the entry belongs to this storage.
+ *
+ * This method will be called for every item in the search results, including results from different storages.
+ * It's the responsibility of this method to return `null` for all results that don't belong to this storage.
+ *
+ * Additionally some implementations might need to further process the resulting entry such as modifying the path
+ * or permissions of the result.
+ *
+ * @param ICacheEntry $rawEntry
+ * @return ICacheEntry|null
+ * @since 22.0.0
+ */
+ public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry;
}