aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Cache
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r--lib/private/Files/Cache/Cache.php145
-rw-r--r--lib/private/Files/Cache/CacheEntry.php3
-rw-r--r--lib/private/Files/Cache/FileAccess.php9
-rw-r--r--lib/private/Files/Cache/Propagator.php16
-rw-r--r--lib/private/Files/Cache/Scanner.php32
-rw-r--r--lib/private/Files/Cache/Updater.php29
-rw-r--r--lib/private/Files/Cache/Watcher.php32
7 files changed, 0 insertions, 266 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index a8d9067050d..e7f1e259e03 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -97,21 +97,10 @@ class Cache implements ICache {
return $this->storageCache;
}
- /**
- * Get the numeric storage id for this cache's storage
- *
- * @return int
- */
public function getNumericStorageId() {
return $this->storageCache->getNumericId();
}
- /**
- * get the stored metadata of a file or folder
- *
- * @param string | int $file either the path of a file or folder or the file id for a file or folder
- * @return ICacheEntry|false the cache entry as array or false if the file is not found in the cache
- */
public function get($file) {
$query = $this->getQueryBuilder();
$query->selectFileCache();
@@ -178,23 +167,11 @@ class Cache implements ICache {
return new CacheEntry($data);
}
- /**
- * get the metadata of all files stored in $folder
- *
- * @param string $folder
- * @return ICacheEntry[]
- */
public function getFolderContents($folder) {
$fileId = $this->getId($folder);
return $this->getFolderContentsById($fileId);
}
- /**
- * get the metadata of all files stored in $folder
- *
- * @param int $fileId the file id of the folder
- * @return ICacheEntry[]
- */
public function getFolderContentsById($fileId) {
if ($fileId > -1) {
$query = $this->getQueryBuilder();
@@ -217,15 +194,6 @@ class Cache implements ICache {
return [];
}
- /**
- * insert or update meta data for a file or folder
- *
- * @param string $file
- * @param array $data
- *
- * @return int file id
- * @throws \RuntimeException
- */
public function put($file, array $data) {
if (($id = $this->getId($file)) > -1) {
$this->update($id, $data);
@@ -235,15 +203,6 @@ class Cache implements ICache {
}
}
- /**
- * insert meta data for a new file or folder
- *
- * @param string $file
- * @param array $data
- *
- * @return int file id
- * @throws \RuntimeException
- */
public function insert($file, array $data) {
// normalize file
$file = $this->normalize($file);
@@ -316,12 +275,6 @@ class Cache implements ICache {
}
}
- /**
- * update the metadata of an existing file or folder in the cache
- *
- * @param int $id the fileid of the existing file or folder
- * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged
- */
public function update($id, array $data) {
if (isset($data['path'])) {
// normalize path
@@ -445,16 +398,6 @@ class Cache implements ICache {
return [$params, array_filter($extensionParams)];
}
- /**
- * 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
- *
- * File ids are easiest way for apps to store references to a file since unlike paths they are not affected by renames or sharing
- *
- * @param string $file
- * @return int
- */
public function getId($file) {
// normalize file
$file = $this->normalize($file);
@@ -472,12 +415,6 @@ class Cache implements ICache {
return $id === false ? -1 : (int)$id;
}
- /**
- * get the id of the parent folder of a file
- *
- * @param string $file
- * @return int
- */
public function getParentId($file) {
if ($file === '') {
return -1;
@@ -495,23 +432,10 @@ class Cache implements ICache {
return $parent;
}
- /**
- * check if a file is available in the cache
- *
- * @param string $file
- * @return bool
- */
public function inCache($file) {
return $this->getId($file) != -1;
}
- /**
- * remove a file or folder from the cache
- *
- * when removing a folder from the cache all files and folders inside the folder will be removed as well
- *
- * @param string $file
- */
public function remove($file) {
$entry = $this->get($file);
@@ -614,12 +538,6 @@ class Cache implements ICache {
}
}
- /**
- * Move a file or folder in the cache
- *
- * @param string $source
- * @param string $target
- */
public function move($source, $target) {
$this->moveFromCache($this, $source, $target);
}
@@ -638,15 +556,6 @@ class Cache implements ICache {
return $this->storage->instanceOfStorage(Encryption::class);
}
- /**
- * Move a file or folder in the cache
- *
- * @param ICache $sourceCache
- * @param string $sourcePath
- * @param string $targetPath
- * @throws \OC\DatabaseException
- * @throws \Exception if the given storages have an invalid id
- */
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
if ($sourceCache instanceof Cache) {
// normalize source and target
@@ -805,18 +714,6 @@ class Cache implements ICache {
$query->execute();
}
- /**
- * Get the scan status of a file
- *
- * - Cache::NOT_FOUND: File is not in the cache
- * - Cache::PARTIAL: File is not stored in the cache but some incomplete data is known
- * - Cache::SHALLOW: The folder and it's direct children are in the cache but not all sub folders are fully scanned
- * - Cache::COMPLETE: The file or folder, with all it's children) are fully scanned
- *
- * @param string $file
- *
- * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE
- */
public function getStatus($file) {
// normalize file
$file = $this->normalize($file);
@@ -846,24 +743,11 @@ class Cache implements ICache {
}
}
- /**
- * search for files matching $pattern
- *
- * @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%')
- * @return ICacheEntry[] an array of cache entries where the name matches the search pattern
- */
public function search($pattern) {
$operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', $pattern);
return $this->searchQuery(new SearchQuery($operator, 0, 0, [], null));
}
- /**
- * 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/*')
- * @return ICacheEntry[] an array of cache entries where the mimetype matches the search
- */
public function searchByMime($mimetype) {
if (!str_contains($mimetype, '/')) {
$operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%');
@@ -1045,15 +929,6 @@ class Cache implements ICache {
}, $files);
}
- /**
- * find a folder in the cache which has not been fully scanned
- *
- * If multiple incomplete folders are in the cache, the one with the highest id will be returned,
- * 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|false the path of the folder or false when no folder matched
- */
public function getIncomplete() {
// we select the fileid here first instead of directly selecting the path since this helps mariadb/mysql
// to use the correct index.
@@ -1079,12 +954,6 @@ class Cache implements ICache {
return $path ?? false;
}
- /**
- * get the path of a file on this storage by it's file id
- *
- * @param int $id the file id of the file or folder to search
- * @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache
- */
public function getPathById($id) {
$query = $this->getQueryBuilder();
$query->select('path')
@@ -1136,24 +1005,10 @@ class Cache implements ICache {
}
}
- /**
- * normalize the given path
- *
- * @param string $path
- * @return string
- */
public function normalize($path) {
return trim(\OC_Util::normalizeUnicode($path), '/');
}
- /**
- * Copy a file or folder in the cache
- *
- * @param ICache $sourceCache
- * @param ICacheEntry $sourceEntry
- * @param string $targetPath
- * @return int fileId of copied entry
- */
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
if ($sourceEntry->getId() < 0) {
throw new \RuntimeException('Invalid source cache entry on copyFromCache');
diff --git a/lib/private/Files/Cache/CacheEntry.php b/lib/private/Files/Cache/CacheEntry.php
index e9417c8012a..19f1dc941d3 100644
--- a/lib/private/Files/Cache/CacheEntry.php
+++ b/lib/private/Files/Cache/CacheEntry.php
@@ -34,9 +34,6 @@ class CacheEntry implements ICacheEntry {
unset($this->data[$offset]);
}
- /**
- * @return mixed
- */
#[\ReturnTypeWillChange]
public function offsetGet($offset) {
if (isset($this->data[$offset])) {
diff --git a/lib/private/Files/Cache/FileAccess.php b/lib/private/Files/Cache/FileAccess.php
index 11a95b5d897..5164318ea1b 100644
--- a/lib/private/Files/Cache/FileAccess.php
+++ b/lib/private/Files/Cache/FileAccess.php
@@ -68,10 +68,6 @@ class FileAccess implements IFileAccess {
return $result;
}
- /**
- * @param int[] $fileIds
- * @return array<int, CacheEntry>
- */
public function getByFileIds(array $fileIds): array {
$query = $this->getQuery()->selectFileCache();
$query->andWhere($query->expr()->in('filecache.fileid', $query->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY)));
@@ -80,11 +76,6 @@ class FileAccess implements IFileAccess {
return $this->rowsToEntries($rows);
}
- /**
- * @param int[] $fileIds
- * @param int $storageId
- * @return array<int, CacheEntry>
- */
public function getByFileIdsInStorage(array $fileIds, int $storageId): array {
$fileIds = array_values($fileIds);
$query = $this->getQuery()->selectFileCache();
diff --git a/lib/private/Files/Cache/Propagator.php b/lib/private/Files/Cache/Propagator.php
index bbeb8c42075..eaf1dabf9aa 100644
--- a/lib/private/Files/Cache/Propagator.php
+++ b/lib/private/Files/Cache/Propagator.php
@@ -46,11 +46,6 @@ class Propagator implements IPropagator {
}
- /**
- * @param string $internalPath
- * @param int $time
- * @param int $sizeDifference number of bytes the file has grown
- */
public function propagateChange($internalPath, $time, $sizeDifference = 0) {
// Do not propagate changes in ignored paths
foreach ($this->ignore as $ignore) {
@@ -142,14 +137,6 @@ class Propagator implements IPropagator {
return $parents;
}
- /**
- * Mark the beginning of a propagation batch
- *
- * Note that not all cache setups support propagation in which case this will be a noop
- *
- * Batching for cache setups that do support it has to be explicit since the cache state is not fully consistent
- * before the batch is committed.
- */
public function beginBatch() {
$this->inBatch = true;
}
@@ -169,9 +156,6 @@ class Propagator implements IPropagator {
}
}
- /**
- * Commit the active propagation batch
- */
public function commitBatch() {
if (!$this->inBatch) {
throw new \BadMethodCallException('Not in batch');
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index c85104ac4b9..3d645fdcb72 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -101,18 +101,6 @@ class Scanner extends BasicEmitter implements IScanner {
return $data;
}
- /**
- * scan a single file and store it in the cache
- *
- * @param string $file
- * @param int $reuseExisting
- * @param int $parentId
- * @param array|null|false $cacheData existing data in the cache for the file to be scanned
- * @param bool $lock set to false to disable getting an additional read lock during scanning
- * @param null $data the metadata for the file, as returned by the storage
- * @return array|null an array of metadata of the scanned file
- * @throws \OCP\Lock\LockedException
- */
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
if ($file !== '') {
try {
@@ -305,15 +293,6 @@ class Scanner extends BasicEmitter implements IScanner {
}
}
- /**
- * scan a folder and all it's children
- *
- * @param string $path
- * @param bool $recursive
- * @param int $reuse
- * @param bool $lock set to false to disable getting an additional read lock during scanning
- * @return array|null an array of the meta data of the scanned file or folder
- */
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
if ($reuse === -1) {
$reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
@@ -553,14 +532,6 @@ class Scanner extends BasicEmitter implements IScanner {
return $childQueue;
}
- /**
- * check if the file should be ignored when scanning
- * NOTE: files with a '.part' extension are ignored as well!
- * prevents unfinished put requests to be scanned
- *
- * @param string $file
- * @return boolean
- */
public static function isPartialFile($file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'part') {
return true;
@@ -572,9 +543,6 @@ class Scanner extends BasicEmitter implements IScanner {
return false;
}
- /**
- * walk over any folders that are not fully scanned yet and scan them
- */
public function backgroundScan() {
if ($this->storage->instanceOfStorage(Jail::class)) {
// for jail storage wrappers (shares, groupfolders) we run the background scan on the source storage
diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php
index eab68b4f545..67329e0e3d9 100644
--- a/lib/private/Files/Cache/Updater.php
+++ b/lib/private/Files/Cache/Updater.php
@@ -71,21 +71,10 @@ class Updater implements IUpdater {
$this->enabled = true;
}
- /**
- * Get the propagator for etags and mtime for the view the updater works on
- *
- * @return Propagator
- */
public function getPropagator() {
return $this->propagator;
}
- /**
- * Propagate etag and mtime changes for the parent folders of $path up to the root of the filesystem
- *
- * @param string $path the path of the file to propagate the changes for
- * @param int|null $time the timestamp to set as mtime for the parent folders, if left out the current time is used
- */
public function propagate($path, $time = null) {
if (Scanner::isPartialFile($path)) {
return;
@@ -93,12 +82,6 @@ class Updater implements IUpdater {
$this->propagator->propagateChange($path, $time);
}
- /**
- * Update the cache for $path and update the size, etag and mtime of the parent folders
- *
- * @param string $path
- * @param int $time
- */
public function update($path, $time = null, ?int $sizeDifference = null) {
if (!$this->enabled or Scanner::isPartialFile($path)) {
return;
@@ -126,11 +109,6 @@ class Updater implements IUpdater {
$this->propagator->propagateChange($path, $time, $sizeDifference ?? 0);
}
- /**
- * Remove $path from the cache and update the size, etag and mtime of the parent folders
- *
- * @param string $path
- */
public function remove($path) {
if (!$this->enabled or Scanner::isPartialFile($path)) {
return;
@@ -156,13 +134,6 @@ class Updater implements IUpdater {
}
}
- /**
- * Rename a file or folder in the cache and update the size, etag and mtime of the parent folders
- *
- * @param IStorage $sourceStorage
- * @param string $source
- * @param string $target
- */
public function renameFromStorage(IStorage $sourceStorage, $source, $target) {
if (!$this->enabled or Scanner::isPartialFile($source) or Scanner::isPartialFile($target)) {
return;
diff --git a/lib/private/Files/Cache/Watcher.php b/lib/private/Files/Cache/Watcher.php
index 2e42b716695..7863d2b71e3 100644
--- a/lib/private/Files/Cache/Watcher.php
+++ b/lib/private/Files/Cache/Watcher.php
@@ -7,7 +7,6 @@
*/
namespace OC\Files\Cache;
-use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Cache\IWatcher;
/**
@@ -42,27 +41,14 @@ class Watcher implements IWatcher {
$this->scanner = $storage->getScanner();
}
- /**
- * @param int $policy either \OC\Files\Cache\Watcher::CHECK_NEVER, \OC\Files\Cache\Watcher::CHECK_ONCE, \OC\Files\Cache\Watcher::CHECK_ALWAYS
- */
public function setPolicy($policy) {
$this->watchPolicy = $policy;
}
- /**
- * @return int either \OC\Files\Cache\Watcher::CHECK_NEVER, \OC\Files\Cache\Watcher::CHECK_ONCE, \OC\Files\Cache\Watcher::CHECK_ALWAYS
- */
public function getPolicy() {
return $this->watchPolicy;
}
- /**
- * check $path for updates and update if needed
- *
- * @param string $path
- * @param ICacheEntry|null $cachedEntry
- * @return boolean true if path was updated
- */
public function checkUpdate($path, $cachedEntry = null) {
if (is_null($cachedEntry)) {
$cachedEntry = $this->cache->get($path);
@@ -82,12 +68,6 @@ class Watcher implements IWatcher {
}
}
- /**
- * Update the cache for changes to $path
- *
- * @param string $path
- * @param ICacheEntry $cachedData
- */
public function update($path, $cachedData) {
if ($this->storage->is_dir($path)) {
$this->scanner->scan($path, Scanner::SCAN_SHALLOW);
@@ -102,13 +82,6 @@ class Watcher implements IWatcher {
}
}
- /**
- * Check if the cache for $path needs to be updated
- *
- * @param string $path
- * @param ICacheEntry $cachedData
- * @return bool
- */
public function needsUpdate($path, $cachedData) {
if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and !in_array($path, $this->checkedPaths))) {
$this->checkedPaths[] = $path;
@@ -117,11 +90,6 @@ class Watcher implements IWatcher {
return false;
}
- /**
- * remove deleted files in $path from the cache
- *
- * @param string $path
- */
public function cleanFolder($path) {
$cachedContent = $this->cache->getFolderContents($path);
foreach ($cachedContent as $entry) {