diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | lib/l10n/fr.js | 10 | ||||
-rw-r--r-- | lib/l10n/fr.json | 10 | ||||
-rw-r--r-- | lib/l10n/tr.js | 1 | ||||
-rw-r--r-- | lib/l10n/tr.json | 1 | ||||
-rw-r--r-- | lib/private/Config.php | 39 | ||||
-rw-r--r-- | lib/private/DB/ConnectionFactory.php | 9 | ||||
-rw-r--r-- | lib/private/Federation/CloudIdManager.php | 25 | ||||
-rw-r--r-- | lib/private/Files/Cache/FileAccess.php | 116 | ||||
-rw-r--r-- | lib/private/Session/Internal.php | 2 | ||||
-rw-r--r-- | lib/public/Files/Cache/IFileAccess.php | 99 |
12 files changed, 279 insertions, 37 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index b575228a7c2..83760755da4 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -319,6 +319,7 @@ return array( 'OCP\\Files\\Cache\\ICache' => $baseDir . '/lib/public/Files/Cache/ICache.php', 'OCP\\Files\\Cache\\ICacheEntry' => $baseDir . '/lib/public/Files/Cache/ICacheEntry.php', 'OCP\\Files\\Cache\\ICacheEvent' => $baseDir . '/lib/public/Files/Cache/ICacheEvent.php', + 'OCP\\Files\\Cache\\IFileAccess' => $baseDir . '/lib/public/Files/Cache/IFileAccess.php', 'OCP\\Files\\Cache\\IPropagator' => $baseDir . '/lib/public/Files/Cache/IPropagator.php', 'OCP\\Files\\Cache\\IScanner' => $baseDir . '/lib/public/Files/Cache/IScanner.php', 'OCP\\Files\\Cache\\IUpdater' => $baseDir . '/lib/public/Files/Cache/IUpdater.php', @@ -1364,6 +1365,7 @@ return array( 'OC\\Files\\Cache\\CacheEntry' => $baseDir . '/lib/private/Files/Cache/CacheEntry.php', 'OC\\Files\\Cache\\CacheQueryBuilder' => $baseDir . '/lib/private/Files/Cache/CacheQueryBuilder.php', 'OC\\Files\\Cache\\FailedCache' => $baseDir . '/lib/private/Files/Cache/FailedCache.php', + 'OC\\Files\\Cache\\FileAccess' => $baseDir . '/lib/private/Files/Cache/FileAccess.php', 'OC\\Files\\Cache\\HomeCache' => $baseDir . '/lib/private/Files/Cache/HomeCache.php', 'OC\\Files\\Cache\\HomePropagator' => $baseDir . '/lib/private/Files/Cache/HomePropagator.php', 'OC\\Files\\Cache\\LocalRootScanner' => $baseDir . '/lib/private/Files/Cache/LocalRootScanner.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index d03df46f06e..56f623cbaee 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -352,6 +352,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Files\\Cache\\ICache' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICache.php', 'OCP\\Files\\Cache\\ICacheEntry' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICacheEntry.php', 'OCP\\Files\\Cache\\ICacheEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/ICacheEvent.php', + 'OCP\\Files\\Cache\\IFileAccess' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/IFileAccess.php', 'OCP\\Files\\Cache\\IPropagator' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/IPropagator.php', 'OCP\\Files\\Cache\\IScanner' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/IScanner.php', 'OCP\\Files\\Cache\\IUpdater' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/IUpdater.php', @@ -1397,6 +1398,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Files\\Cache\\CacheEntry' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/CacheEntry.php', 'OC\\Files\\Cache\\CacheQueryBuilder' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/CacheQueryBuilder.php', 'OC\\Files\\Cache\\FailedCache' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/FailedCache.php', + 'OC\\Files\\Cache\\FileAccess' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/FileAccess.php', 'OC\\Files\\Cache\\HomeCache' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/HomeCache.php', 'OC\\Files\\Cache\\HomePropagator' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/HomePropagator.php', 'OC\\Files\\Cache\\LocalRootScanner' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/LocalRootScanner.php', diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js index 11cac1289af..99ec395a003 100644 --- a/lib/l10n/fr.js +++ b/lib/l10n/fr.js @@ -6,7 +6,7 @@ OC.L10N.register( "But, if you prefer to keep config.php file read only, set the option \"config_is_read_only\" to true in it." : "Ou, si vous préférez conserver le fichier config.php en lecture seule, définissez l'option « config_is_read_only » sur true.", "See %s" : "Voir %s", "Application %1$s is not present or has a non-compatible version with this server. Please check the apps directory." : "L'application %1$s n'est pas présente ou n'est pas compatible avec cette version du serveur. Veuillez vérifier le répertoire des applications.", - "Sample configuration detected" : "Configuration d'exemple détectée", + "Sample configuration detected" : "Configuration d’exemple détectée", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Il a été détecté que la configuration donnée à titre d'exemple a été copiée. Cela peut rendre votre installation inopérante et n'est pas pris en charge. Veuillez lire la documentation avant d'effectuer des modifications dans config.php", "The page could not be found on the server." : "La page n'a pas pu être trouvée sur le serveur.", "%s email verification" : "Vérification de l'e-mail %s", @@ -30,7 +30,7 @@ OC.L10N.register( "The following architectures are supported: %s" : "Les architectures suivantes sont prises en charge : %s", "The following databases are supported: %s" : "Les bases de données suivantes sont prises en charge : %s", "The command line tool %s could not be found" : "La commande %s est introuvable", - "The library %s is not available." : "La librairie %s n'est pas disponible.", + "The library %s is not available." : "La librairie %s n’est pas disponible.", "Library %1$s with a version higher than %2$s is required - available version %3$s." : "La librairie %1$s doit être au moins à la version %2$s. Version disponible : %3$s.", "Library %1$s with a version lower than %2$s is required - available version %3$s." : "La librairie %1$s doit avoir une version antérieure à %2$s. Version disponible : %3$s.", "The following platforms are supported: %s" : "Les plateformes suivantes sont prises en charge : %s", @@ -58,7 +58,7 @@ OC.L10N.register( "Files" : "Fichiers", "View profile" : "Voir le profil", "Local time: %s" : "Heure locale : %s", - "today" : "aujourd'hui", + "today" : "aujourd’hui", "tomorrow" : "demain", "yesterday" : "hier", "_in %n day_::_in %n days_" : ["dans %n jour","dans %n jours","dans %n jours"], @@ -68,7 +68,7 @@ OC.L10N.register( "_in %n month_::_in %n months_" : ["dans %n mois","dans %n mois","dans %n mois"], "_%n month ago_::_%n months ago_" : ["Il y a %n mois","Il y a %n mois","Il y a %n mois"], "next year" : "année suivante", - "last year" : "l'année dernière", + "last year" : "l’année dernière", "_in %n year_::_in %n years_" : ["dans %n an","dans %n ans","dans %n ans"], "_%n year ago_::_%n years ago_" : ["il y a %n an","il y a %n ans","il y a %n ans"], "_in %n hour_::_in %n hours_" : ["dans %n heure","dans %n heures","dans %n heures"], @@ -143,7 +143,7 @@ OC.L10N.register( "»%s« added a note to a file shared with you" : "%s a ajouté une note à un fichier partagé avec vous", "Open »%s«" : "Ouvrir « %s »", "%1$s via %2$s" : "%1$s via %2$s", - "You are not allowed to share %s" : "Vous n'êtes pas autorisé à partager %s", + "You are not allowed to share %s" : "Vous n’êtes pas autorisé à partager %s", "Cannot increase permissions of %s" : "Impossible d'augmenter les permissions de %s", "Files cannot be shared with delete permissions" : "Les fichiers ne peuvent pas être partagés avec les autorisations de suppression", "Files cannot be shared with create permissions" : "Les fichiers ne peuvent pas être partagés avec les autorisations de création", diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json index 512f87baf42..80812e53cbf 100644 --- a/lib/l10n/fr.json +++ b/lib/l10n/fr.json @@ -4,7 +4,7 @@ "But, if you prefer to keep config.php file read only, set the option \"config_is_read_only\" to true in it." : "Ou, si vous préférez conserver le fichier config.php en lecture seule, définissez l'option « config_is_read_only » sur true.", "See %s" : "Voir %s", "Application %1$s is not present or has a non-compatible version with this server. Please check the apps directory." : "L'application %1$s n'est pas présente ou n'est pas compatible avec cette version du serveur. Veuillez vérifier le répertoire des applications.", - "Sample configuration detected" : "Configuration d'exemple détectée", + "Sample configuration detected" : "Configuration d’exemple détectée", "It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php" : "Il a été détecté que la configuration donnée à titre d'exemple a été copiée. Cela peut rendre votre installation inopérante et n'est pas pris en charge. Veuillez lire la documentation avant d'effectuer des modifications dans config.php", "The page could not be found on the server." : "La page n'a pas pu être trouvée sur le serveur.", "%s email verification" : "Vérification de l'e-mail %s", @@ -28,7 +28,7 @@ "The following architectures are supported: %s" : "Les architectures suivantes sont prises en charge : %s", "The following databases are supported: %s" : "Les bases de données suivantes sont prises en charge : %s", "The command line tool %s could not be found" : "La commande %s est introuvable", - "The library %s is not available." : "La librairie %s n'est pas disponible.", + "The library %s is not available." : "La librairie %s n’est pas disponible.", "Library %1$s with a version higher than %2$s is required - available version %3$s." : "La librairie %1$s doit être au moins à la version %2$s. Version disponible : %3$s.", "Library %1$s with a version lower than %2$s is required - available version %3$s." : "La librairie %1$s doit avoir une version antérieure à %2$s. Version disponible : %3$s.", "The following platforms are supported: %s" : "Les plateformes suivantes sont prises en charge : %s", @@ -56,7 +56,7 @@ "Files" : "Fichiers", "View profile" : "Voir le profil", "Local time: %s" : "Heure locale : %s", - "today" : "aujourd'hui", + "today" : "aujourd’hui", "tomorrow" : "demain", "yesterday" : "hier", "_in %n day_::_in %n days_" : ["dans %n jour","dans %n jours","dans %n jours"], @@ -66,7 +66,7 @@ "_in %n month_::_in %n months_" : ["dans %n mois","dans %n mois","dans %n mois"], "_%n month ago_::_%n months ago_" : ["Il y a %n mois","Il y a %n mois","Il y a %n mois"], "next year" : "année suivante", - "last year" : "l'année dernière", + "last year" : "l’année dernière", "_in %n year_::_in %n years_" : ["dans %n an","dans %n ans","dans %n ans"], "_%n year ago_::_%n years ago_" : ["il y a %n an","il y a %n ans","il y a %n ans"], "_in %n hour_::_in %n hours_" : ["dans %n heure","dans %n heures","dans %n heures"], @@ -141,7 +141,7 @@ "»%s« added a note to a file shared with you" : "%s a ajouté une note à un fichier partagé avec vous", "Open »%s«" : "Ouvrir « %s »", "%1$s via %2$s" : "%1$s via %2$s", - "You are not allowed to share %s" : "Vous n'êtes pas autorisé à partager %s", + "You are not allowed to share %s" : "Vous n’êtes pas autorisé à partager %s", "Cannot increase permissions of %s" : "Impossible d'augmenter les permissions de %s", "Files cannot be shared with delete permissions" : "Les fichiers ne peuvent pas être partagés avec les autorisations de suppression", "Files cannot be shared with create permissions" : "Les fichiers ne peuvent pas être partagés avec les autorisations de création", diff --git a/lib/l10n/tr.js b/lib/l10n/tr.js index ebd604aec76..bb38c22f15d 100644 --- a/lib/l10n/tr.js +++ b/lib/l10n/tr.js @@ -23,6 +23,7 @@ OC.L10N.register( "Enterprise bundle" : "Kurumsal paket", "Groupware bundle" : "Grup çalışması paketi", "Hub bundle" : "Toplayıcı paketi", + "Public sector bundle" : "Kamu sektörü paketi", "Social sharing bundle" : "Sosyal ağ paketi", "PHP %s or higher is required." : "PHP %s ya da daha sonraki bir sürümü gerekli.", "PHP with a version lower than %s is required." : "PHP %s ya da daha önceki bir sürümü gerekli.", diff --git a/lib/l10n/tr.json b/lib/l10n/tr.json index 09623974930..03b451db044 100644 --- a/lib/l10n/tr.json +++ b/lib/l10n/tr.json @@ -21,6 +21,7 @@ "Enterprise bundle" : "Kurumsal paket", "Groupware bundle" : "Grup çalışması paketi", "Hub bundle" : "Toplayıcı paketi", + "Public sector bundle" : "Kamu sektörü paketi", "Social sharing bundle" : "Sosyal ağ paketi", "PHP %s or higher is required." : "PHP %s ya da daha sonraki bir sürümü gerekli.", "PHP with a version lower than %s is required." : "PHP %s ya da daha önceki bir sürümü gerekli.", diff --git a/lib/private/Config.php b/lib/private/Config.php index 3ea822101df..803ce859de4 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -215,13 +215,24 @@ class Config { // Include file and merge config foreach ($configFiles as $file) { - $fileExistsAndIsReadable = file_exists($file) && is_readable($file); - $filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false; - if ($file === $this->configFilePath && - $filePointer === false) { - // Opening the main config might not be possible, e.g. if the wrong - // permissions are set (likely on a new installation) - continue; + unset($CONFIG); + + // Invalidate opcache (only if the timestamp changed) + if (function_exists('opcache_invalidate')) { + opcache_invalidate($file, false); + } + + $filePointer = @fopen($file, 'r'); + if ($filePointer === false) { + // e.g. wrong permissions are set + if ($file === $this->configFilePath) { + // opening the main config file might not be possible + // (likely on a new installation) + continue; + } + + http_response_code(500); + die(sprintf('FATAL: Could not open the config file %s', $file)); } // Try to acquire a file lock @@ -229,8 +240,14 @@ class Config { throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file)); } - unset($CONFIG); - include $file; + try { + include $file; + } finally { + // Close the file pointer and release the lock + flock($filePointer, LOCK_UN); + fclose($filePointer); + } + if (!defined('PHPUNIT_RUN') && headers_sent()) { // syntax issues in the config file like leading spaces causing PHP to send output $errorMessage = sprintf('Config file has leading content, please remove everything before "<?php" in %s', basename($file)); @@ -242,10 +259,6 @@ class Config { if (isset($CONFIG) && is_array($CONFIG)) { $this->cache = array_merge($this->cache, $CONFIG); } - - // Close the file pointer and release the lock - flock($filePointer, LOCK_UN); - fclose($filePointer); } $this->envCache = getenv(); diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index e868f18ec34..c7a558e5879 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -128,6 +128,15 @@ class ConnectionFactory { $eventManager->addEventSubscriber(new SetTransactionIsolationLevel()); $additionalConnectionParams = array_merge($this->createConnectionParams(), $additionalConnectionParams); switch ($normalizedType) { + case 'pgsql': + // pg_connect used by Doctrine DBAL does not support URI notation (enclosed in brackets) + $matches = []; + if (preg_match('/^\[([^\]]+)\]$/', $additionalConnectionParams['host'], $matches)) { + // Host variable carries a port or socket. + $additionalConnectionParams['host'] = $matches[1]; + } + break; + case 'oci': $eventManager->addEventSubscriber(new OracleSessionInit); // the driverOptions are unused in dbal and need to be mapped to the parameters diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php index 22b06af386f..70431ce2289 100644 --- a/lib/private/Federation/CloudIdManager.php +++ b/lib/private/Federation/CloudIdManager.php @@ -168,17 +168,16 @@ class CloudIdManager implements ICloudIdManager { public function getCloudId(string $user, ?string $remote): ICloudId { $isLocal = $remote === null; if ($isLocal) { - $remote = rtrim($this->removeProtocolFromUrl($this->urlGenerator->getAbsoluteURL('/')), '/'); - $fixedRemote = $this->fixRemoteURL($remote); - $host = $fixedRemote; - } else { - // note that for remote id's we don't strip the protocol for the remote we use to construct the CloudId - // this way if a user has an explicit non-https cloud id this will be preserved - // we do still use the version without protocol for looking up the display name - $fixedRemote = $this->fixRemoteURL($remote); - $host = $this->removeProtocolFromUrl($fixedRemote); + $remote = rtrim($this->urlGenerator->getAbsoluteURL('/'), '/'); } + // note that for remote id's we don't strip the protocol for the remote we use to construct the CloudId + // this way if a user has an explicit non-https cloud id this will be preserved + // we do still use the version without protocol for looking up the display name + $remote = $this->removeProtocolFromUrl($remote, true); + $remote = $this->fixRemoteURL($remote); + $host = $this->removeProtocolFromUrl($remote); + $key = $user . '@' . ($isLocal ? 'local' : $host); $cached = $this->cache[$key] ?? $this->memCache->get($key); if ($cached) { @@ -197,23 +196,23 @@ class CloudIdManager implements ICloudIdManager { $data = [ 'id' => $id, 'user' => $user, - 'remote' => $fixedRemote, + 'remote' => $remote, 'displayName' => $displayName, ]; $this->cache[$key] = $data; $this->memCache->set($key, $data, 15 * 60); - return new CloudId($id, $user, $fixedRemote, $displayName); + return new CloudId($id, $user, $remote, $displayName); } /** * @param string $url * @return string */ - public function removeProtocolFromUrl(string $url): string { + public function removeProtocolFromUrl(string $url, bool $httpsOnly = false): string { if (str_starts_with($url, 'https://')) { return substr($url, 8); } - if (str_starts_with($url, 'http://')) { + if (!$httpsOnly && str_starts_with($url, 'http://')) { return substr($url, 7); } diff --git a/lib/private/Files/Cache/FileAccess.php b/lib/private/Files/Cache/FileAccess.php new file mode 100644 index 00000000000..a75056a271d --- /dev/null +++ b/lib/private/Files/Cache/FileAccess.php @@ -0,0 +1,116 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2024 Robin Appelman <robin@icewind.nl> + * + * @author Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OC\Files\Cache; + +use OC\FilesMetadata\FilesMetadataManager; +use OC\SystemConfig; +use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\Files\Cache\IFileAccess; +use OCP\Files\IMimeTypeLoader; +use OCP\IDBConnection; +use Psr\Log\LoggerInterface; + +/** + * Low level access to the file cache + */ +class FileAccess implements IFileAccess { + public function __construct( + private IDBConnection $connection, + private SystemConfig $systemConfig, + private LoggerInterface $logger, + private FilesMetadataManager $metadataManager, + private IMimeTypeLoader $mimeTypeLoader, + ) { + } + + private function getQuery(): CacheQueryBuilder { + return new CacheQueryBuilder( + $this->connection, + $this->systemConfig, + $this->logger, + $this->metadataManager, + ); + } + + public function getByFileIdInStorage(int $fileId, int $storageId): ?CacheEntry { + $items = $this->getByFileIdsInStorage([$fileId], $storageId); + return $items[0] ?? null; + } + + public function getByPathInStorage(string $path, int $storageId): ?CacheEntry { + $query = $this->getQuery()->selectFileCache(); + $query->andWhere($query->expr()->eq('filecache.path_hash', $query->createNamedParameter(md5($path)))); + $query->andWhere($query->expr()->eq('filecache.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); + + $row = $query->executeQuery()->fetch(); + return $row ? Cache::cacheEntryFromData($row, $this->mimeTypeLoader) : null; + } + + public function getByFileId(int $fileId): ?CacheEntry { + $items = $this->getByFileIds([$fileId]); + return $items[0] ?? null; + } + + /** + * @param array[] $rows + * @return array<int, CacheEntry> + */ + private function rowsToEntries(array $rows): array { + $result = []; + foreach ($rows as $row) { + $entry = Cache::cacheEntryFromData($row, $this->mimeTypeLoader); + $result[$entry->getId()] = $entry; + } + 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))); + + $rows = $query->executeQuery()->fetchAll(); + 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(); + $query->andWhere($query->expr()->in('filecache.fileid', $query->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY))); + $query->andWhere($query->expr()->eq('filecache.storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); + + $rows = $query->executeQuery()->fetchAll(); + return $this->rowsToEntries($rows); + } +} diff --git a/lib/private/Session/Internal.php b/lib/private/Session/Internal.php index 5fb9b05c5f4..6c0e8538684 100644 --- a/lib/private/Session/Internal.php +++ b/lib/private/Session/Internal.php @@ -121,7 +121,7 @@ class Internal extends Session { * Wrapper around session_regenerate_id * * @param bool $deleteOldSession Whether to delete the old associated session file or not. - * @param bool $updateToken Wheater to update the associated auth token + * @param bool $updateToken Whether to update the associated auth token * @return void */ public function regenerateId(bool $deleteOldSession = true, bool $updateToken = false) { diff --git a/lib/public/Files/Cache/IFileAccess.php b/lib/public/Files/Cache/IFileAccess.php new file mode 100644 index 00000000000..87918bf332d --- /dev/null +++ b/lib/public/Files/Cache/IFileAccess.php @@ -0,0 +1,99 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2024 Robin Appelman <robin@icewind.nl> + * + * @author Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\Files\Cache; + +/** + * Low level access to the file cache. + * + * This is intended for use cases where data from the filecache needs to be loaded, but the full filesystem apis are + * insufficient or too inefficient for the use-case. + * + * @since 29.0.0 + */ +interface IFileAccess { + /** + * Get a filecache data by file id from a specific storage. + * + * This is preferred over `getByFileId` when the storage id is known as it + * can be more efficient in some setups. + * + * @param int $fileId + * @param int $storageId + * @return ICacheEntry|null + * + * @since 29.0.0 + */ + public function getByFileIdInStorage(int $fileId, int $storageId): ?ICacheEntry; + + /** + * Get a filecache data by path and storage id. + * + * @param string $path + * @param int $storageId + * @return ICacheEntry|null + * + * @since 29.0.0 + */ + public function getByPathInStorage(string $path, int $storageId): ?ICacheEntry; + + /** + * Get a filecache data by file id. + * + * If the storage id is known then `getByFileIdInStorage` is preferred as it can be more efficient in some setups. + * + * @param int $fileId + * @return ICacheEntry|null + * + * @since 29.0.0 + */ + public function getByFileId(int $fileId): ?ICacheEntry; + + /** + * Get filecache data by file ids. + * + * If the storage id is known then `getByFileIdsInStorage` is preferred as it can be more efficient in some setups. + * + * @param int[] $fileIds + * @return array<int, ICacheEntry> + * + * @since 29.0.0 + */ + public function getByFileIds(array $fileIds): array; + + /** + * Get filecache data by file ids from a specific storage. + * + * This is prefered over `getByFileIds` when the storage id is known as it + * can be more efficient in some setups. + * + * @param int[] $fileIds + * @param int $storageId + * @return array<int, ICacheEntry> + * + * @since 29.0.0 + */ + public function getByFileIdsInStorage(array $fileIds, int $storageId): array; +} |