From e62e9e3dbf1a2573554b1a9eabbf5b59b652dae6 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 7 Nov 2023 00:21:29 -0100 Subject: IFilesMetadata Signed-off-by: Maxence Lange --- apps/dav/lib/Connector/Sabre/FilesPlugin.php | 9 ++- apps/dav/lib/Files/FileSearchBackend.php | 102 ++++++++++++++++----------- apps/dav/lib/Server.php | 5 +- 3 files changed, 72 insertions(+), 44 deletions(-) (limited to 'apps/dav') diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 709a4cd68ed..9319327d094 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -7,6 +7,7 @@ * @author Christoph Wurst * @author Joas Schilling * @author Lukas Reschke + * @author Maxence Lange * @author Michael Jobst * @author Morris Jobke * @author Robin Appelman @@ -49,8 +50,8 @@ use Sabre\DAV\IFile; use Sabre\DAV\INode; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; -use Sabre\DAV\ServerPlugin; use Sabre\DAV\Server; +use Sabre\DAV\ServerPlugin; use Sabre\DAV\Tree; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; @@ -84,6 +85,7 @@ class FilesPlugin extends ServerPlugin { public const SHARE_NOTE = '{http://nextcloud.org/ns}note'; public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count'; public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count'; + public const FILE_METADATA_PREFIX = '{http://nextcloud.org/ns}metadata-'; public const FILE_METADATA_SIZE = '{http://nextcloud.org/ns}file-metadata-size'; public const FILE_METADATA_GPS = '{http://nextcloud.org/ns}file-metadata-gps'; @@ -389,6 +391,11 @@ class FilesPlugin extends ServerPlugin { $propFind->handle(self::CREATION_TIME_PROPERTYNAME, function () use ($node) { return $node->getFileInfo()->getCreationTime(); }); + + foreach ($node->getFileInfo()->getMetadata() as $metadataKey => $metadataValue) { + $propFind->handle(self::FILE_METADATA_PREFIX . $metadataKey, $metadataValue); + } + /** * Return file/folder name as displayname. The primary reason to * implement it this way is to avoid costly fallback to diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index 524f90e6623..658ad34ec32 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -4,6 +4,7 @@ * * @author Christian <16852529+cviereck@users.noreply.github.com> * @author Christoph Wurst + * @author Maxence Lange * @author Robin Appelman * @author Roeland Jago Douma * @@ -42,6 +43,9 @@ use OCP\Files\Node; use OCP\Files\Search\ISearchOperator; use OCP\Files\Search\ISearchOrder; use OCP\Files\Search\ISearchQuery; +use OCP\FilesMetadata\IFilesMetadataManager; +use OCP\FilesMetadata\Model\IMetadataQuery; +use OCP\FilesMetadata\Model\IMetadataValueWrapper; use OCP\IUser; use OCP\Share\IManager; use Sabre\DAV\Exception\NotFound; @@ -57,37 +61,14 @@ use SearchDAV\Query\Query; class FileSearchBackend implements ISearchBackend { public const OPERATOR_LIMIT = 100; - /** @var CachingTree */ - private $tree; - - /** @var IUser */ - private $user; - - /** @var IRootFolder */ - private $rootFolder; - - /** @var IManager */ - private $shareManager; - - /** @var View */ - private $view; - - /** - * FileSearchBackend constructor. - * - * @param CachingTree $tree - * @param IUser $user - * @param IRootFolder $rootFolder - * @param IManager $shareManager - * @param View $view - * @internal param IRootFolder $rootFolder - */ - public function __construct(CachingTree $tree, IUser $user, IRootFolder $rootFolder, IManager $shareManager, View $view) { - $this->tree = $tree; - $this->user = $user; - $this->rootFolder = $rootFolder; - $this->shareManager = $shareManager; - $this->view = $view; + public function __construct( + private CachingTree $tree, + private IUser $user, + private IRootFolder $rootFolder, + private IManager $shareManager, + private View $view, + private IFilesMetadataManager $filesMetadataManager, + ) { } /** @@ -115,7 +96,7 @@ class FileSearchBackend implements ISearchBackend { // all valid scopes support the same schema //todo dynamically load all propfind properties that are supported - return [ + $props = [ // queryable properties new SearchPropertyDefinition('{DAV:}displayname', true, true, true), new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), @@ -137,6 +118,33 @@ class FileSearchBackend implements ISearchBackend { new SearchPropertyDefinition(FilesPlugin::FILE_METADATA_SIZE, true, false, false, SearchPropertyDefinition::DATATYPE_STRING), new SearchPropertyDefinition(FilesPlugin::FILEID_PROPERTYNAME, true, false, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), ]; + + return array_merge($props, $this->getPropertyDefinitionsForMetadata()); + } + + + private function getPropertyDefinitionsForMetadata(): array { + $metadataProps = []; + $metadata = $this->filesMetadataManager->getKnownMetadata(); + $indexes = $metadata->getIndexes(); + foreach ($metadata->getKeys() as $key) { + $isIndex = in_array($key, $indexes); + $type = match ($metadata->getType($key)) { + IMetadataValueWrapper::TYPE_INT => SearchPropertyDefinition::DATATYPE_INTEGER, + IMetadataValueWrapper::TYPE_FLOAT => SearchPropertyDefinition::DATATYPE_DECIMAL, + IMetadataValueWrapper::TYPE_BOOL => SearchPropertyDefinition::DATATYPE_BOOLEAN, + default => SearchPropertyDefinition::DATATYPE_STRING + }; + $metadataProps[] = new SearchPropertyDefinition( + FilesPlugin::FILE_METADATA_PREFIX . $key, + true, + $isIndex, + $isIndex, + $type + ); + } + + return $metadataProps; } /** @@ -300,11 +308,20 @@ class FileSearchBackend implements ISearchBackend { /** * @param Query $query + * * @return ISearchQuery */ private function transformQuery(Query $query): ISearchQuery { + $orders = array_map(function (Order $order): ISearchOrder { + $direction = $order->order === Order::ASC ? ISearchOrder::DIRECTION_ASCENDING : ISearchOrder::DIRECTION_DESCENDING; + if (str_starts_with($order->property->name, FilesPlugin::FILE_METADATA_PREFIX)) { + return new SearchOrder($direction, substr($order->property->name, strlen(FilesPlugin::FILE_METADATA_PREFIX)), IMetadataQuery::EXTRA); + } else { + return new SearchOrder($direction, $this->mapPropertyNameToColumn($order->property)); + } + }, $query->orderBy); + $limit = $query->limit; - $orders = array_map([$this, 'mapSearchOrder'], $query->orderBy); $offset = $limit->firstResult; $limitHome = false; @@ -352,14 +369,6 @@ class FileSearchBackend implements ISearchBackend { } } - /** - * @param Order $order - * @return ISearchOrder - */ - private function mapSearchOrder(Order $order) { - return new SearchOrder($order->order === Order::ASC ? ISearchOrder::DIRECTION_ASCENDING : ISearchOrder::DIRECTION_DESCENDING, $this->mapPropertyNameToColumn($order->property)); - } - /** * @param Operator $operator * @return ISearchOperator @@ -387,7 +396,16 @@ class FileSearchBackend implements ISearchBackend { if (!($operator->arguments[1] instanceof Literal)) { throw new \InvalidArgumentException('Invalid argument 2 for ' . $trimmedType . ' operation, expected literal'); } - return new SearchComparison($trimmedType, $this->mapPropertyNameToColumn($operator->arguments[0]), $this->castValue($operator->arguments[0], $operator->arguments[1]->value)); + + $property = $operator->arguments[0]; + $value = $this->castValue($property, $operator->arguments[1]->value); + if (str_starts_with($property->name, FilesPlugin::FILE_METADATA_PREFIX)) { + return new SearchComparison($trimmedType, substr($property->name, strlen(FilesPlugin::FILE_METADATA_PREFIX)), $value, IMetadataQuery::EXTRA); + } else { + return new SearchComparison($trimmedType, $this->mapPropertyNameToColumn($property), $value); + } + + // no break case Operator::OPERATION_IS_COLLECTION: return new SearchComparison('eq', 'mimetype', ICacheEntry::DIRECTORY_MIMETYPE); default: diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 603e015fca9..15b97d028cc 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -11,6 +11,7 @@ * @author Joas Schilling * @author John Molakvoæ * @author Lukas Reschke + * @author Maxence Lange * @author Morris Jobke * @author Robin Appelman * @author Roeland Jago Douma @@ -76,6 +77,7 @@ use OCA\DAV\Upload\ChunkingV2Plugin; use OCP\AppFramework\Http\Response; use OCP\Diagnostics\IEventLogger; use OCP\EventDispatcher\IEventDispatcher; +use OCP\FilesMetadata\IFilesMetadataManager; use OCP\ICacheFactory; use OCP\IRequest; use OCP\Profiler\IProfiler; @@ -316,7 +318,8 @@ class Server { $user, \OC::$server->getRootFolder(), \OC::$server->getShareManager(), - $view + $view, + \OCP\Server::get(IFilesMetadataManager::class) )); $this->server->addPlugin( new BulkUploadPlugin( -- cgit v1.2.3 From f497d8b6e5a42635ec181dfeda404862ee4c8e3d Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 7 Nov 2023 12:43:01 -0100 Subject: IFilesMetadata Signed-off-by: Maxence Lange --- apps/dav/tests/unit/Files/FileSearchBackendTest.php | 5 ++++- core/Command/FilesMetadata/Get.php | 4 ++-- lib/private/Files/Cache/SearchBuilder.php | 2 +- lib/private/Files/Node/Folder.php | 2 -- .../Files/Search/QueryOptimizer/PathPrefixOptimizer.php | 4 ++-- lib/private/Files/Search/SearchComparison.php | 16 +++++++++------- lib/private/Files/Search/SearchOrder.php | 8 ++++---- lib/private/FilesMetadata/FilesMetadataManager.php | 9 +++++---- lib/private/FilesMetadata/Job/UpdateSingleMetadata.php | 5 ++++- lib/private/FilesMetadata/Listener/MetadataDelete.php | 3 +++ lib/private/FilesMetadata/Listener/MetadataUpdate.php | 3 +++ lib/public/Files/Search/ISearchComparison.php | 15 +++------------ lib/public/Files/Search/ISearchOrder.php | 9 --------- lib/public/FilesMetadata/IFilesMetadataManager.php | 10 ++++++---- lib/public/FilesMetadata/Model/IMetadataQuery.php | 1 + 15 files changed, 47 insertions(+), 49 deletions(-) (limited to 'apps/dav') diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php index 715130d2fae..ea841140201 100644 --- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php +++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php @@ -41,6 +41,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchQuery; +use OCP\FilesMetadata\IFilesMetadataManager; use OCP\IUser; use OCP\Share\IManager; use SearchDAV\Backend\SearchPropertyDefinition; @@ -114,7 +115,9 @@ class FileSearchBackendTest extends TestCase { ->method('get') ->willReturn($this->searchFolder); - $this->search = new FileSearchBackend($this->tree, $this->user, $this->rootFolder, $this->shareManager, $this->view); + $filesMetadataManager = $this->createMock(IFilesMetadataManager::class); + + $this->search = new FileSearchBackend($this->tree, $this->user, $this->rootFolder, $this->shareManager, $this->view, $filesMetadataManager); } public function testSearchFilename(): void { diff --git a/core/Command/FilesMetadata/Get.php b/core/Command/FilesMetadata/Get.php index aebabe63e35..99bc167f71d 100644 --- a/core/Command/FilesMetadata/Get.php +++ b/core/Command/FilesMetadata/Get.php @@ -91,7 +91,7 @@ class Get extends Command { if ($input->getOption('reset')) { $this->filesMetadataManager->deleteMetadata($fileId); if (!$input->getOption('refresh')) { - return 0; + return self::SUCCESS; } } @@ -114,6 +114,6 @@ class Get extends Command { $output->writeln(json_encode($metadata, JSON_PRETTY_PRINT)); } - return 0; + return self::SUCCESS; } } diff --git a/lib/private/Files/Cache/SearchBuilder.php b/lib/private/Files/Cache/SearchBuilder.php index ba4aabf2b4f..1f9a6af931b 100644 --- a/lib/private/Files/Cache/SearchBuilder.php +++ b/lib/private/Files/Cache/SearchBuilder.php @@ -78,7 +78,7 @@ class SearchBuilder { return array_reduce($operator->getArguments(), function (array $fields, ISearchOperator $operator) { return array_unique(array_merge($fields, $this->extractRequestedFields($operator))); }, []); - } elseif ($operator instanceof ISearchComparison && !$operator->isExtra()) { + } elseif ($operator instanceof ISearchComparison && !$operator->getExtra()) { return [$operator->getField()]; } return []; diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index eba7ce1d77e..c7462572fed 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -252,8 +252,6 @@ class Folder extends Node implements \OCP\Files\Folder { if ($order) { usort($files, function (FileInfo $a, FileInfo $b) use ($order) { foreach ($order as $orderField) { - // needed !? - // if ($orderField->isExtra()) { continue; } $cmp = $orderField->sortFileInfo($a, $b); if ($cmp !== 0) { return $cmp; diff --git a/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php b/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php index cf9e6ad5b91..664402f1238 100644 --- a/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php +++ b/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php @@ -51,7 +51,7 @@ class PathPrefixOptimizer extends QueryOptimizerStep { } public function processOperator(ISearchOperator &$operator) { - if (!$this->useHashEq && $operator instanceof ISearchComparison && !$operator->isExtra() && $operator->getField() === 'path' && $operator->getType() === ISearchComparison::COMPARE_EQUAL) { + if (!$this->useHashEq && $operator instanceof ISearchComparison && !$operator->getExtra() && $operator->getField() === 'path' && $operator->getType() === ISearchComparison::COMPARE_EQUAL) { $operator->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, false); } @@ -72,7 +72,7 @@ class PathPrefixOptimizer extends QueryOptimizerStep { private function operatorPairIsPathPrefix(ISearchOperator $like, ISearchOperator $equal): bool { return ( $like instanceof ISearchComparison && $equal instanceof ISearchComparison && - !$like->isExtra() && !$equal->isExtra() && $like->getField() === 'path' && $equal->getField() === 'path' && + !$like->getExtra() && !$equal->getExtra() && $like->getField() === 'path' && $equal->getField() === 'path' && $like->getType() === ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE && $equal->getType() === ISearchComparison::COMPARE_EQUAL && $like->getValue() === SearchComparison::escapeLikeParameter($equal->getValue()) . '/%' ); diff --git a/lib/private/Files/Search/SearchComparison.php b/lib/private/Files/Search/SearchComparison.php index 5caa632f618..4f9ac266397 100644 --- a/lib/private/Files/Search/SearchComparison.php +++ b/lib/private/Files/Search/SearchComparison.php @@ -1,4 +1,6 @@ * @@ -39,32 +41,32 @@ class SearchComparison implements ISearchComparison { /** * @return string */ - public function getType() { + public function getType(): string { return $this->type; } /** * @return string */ - public function getField() { + public function getField(): string { return $this->field; } /** * @return \DateTime|int|string */ - public function getValue() { + public function getValue(): string|int|\DateTime { return $this->value; } + /** + * @return string + * @since 28.0.0 + */ public function getExtra(): string { return $this->extra; } - public function isExtra(): bool { - return ($this->extra !== ''); - } - public function getQueryHint(string $name, $default) { return $this->hints[$name] ?? $default; } diff --git a/lib/private/Files/Search/SearchOrder.php b/lib/private/Files/Search/SearchOrder.php index ca974ca9c03..de514262bf5 100644 --- a/lib/private/Files/Search/SearchOrder.php +++ b/lib/private/Files/Search/SearchOrder.php @@ -48,14 +48,14 @@ class SearchOrder implements ISearchOrder { return $this->field; } + /** + * @return string + * @since 28.0.0 + */ public function getExtra(): string { return $this->extra; } - public function isExtra(): bool { - return ($this->extra !== ''); - } - public function sortFileInfo(FileInfo $a, FileInfo $b): int { $cmp = $this->sortFileInfoNoDirection($a, $b); return $cmp * ($this->direction === ISearchOrder::DIRECTION_ASCENDING ? 1 : -1); diff --git a/lib/private/FilesMetadata/FilesMetadataManager.php b/lib/private/FilesMetadata/FilesMetadataManager.php index 7e941234ce3..54310f934d7 100644 --- a/lib/private/FilesMetadata/FilesMetadataManager.php +++ b/lib/private/FilesMetadata/FilesMetadataManager.php @@ -242,6 +242,7 @@ class FilesMetadataManager implements IFilesMetadataManager { /** * @param string $key metadata key * @param string $type metadata type + * @param bool $indexed TRUE if metadata can be search * * @inheritDoc * @since 28.0.0 @@ -253,17 +254,17 @@ class FilesMetadataManager implements IFilesMetadataManager { * @see IMetadataValueWrapper::TYPE_INT_LIST * @see IMetadataValueWrapper::TYPE_STRING */ - public function initMetadataIndex(string $key, string $type): void { + public function initMetadata(string $key, string $type, bool $indexed): void { $current = $this->getKnownMetadata(); try { - if ($current->getType($key) === $type && $current->isIndex($key)) { - return; // if key exists, with same type and is already indexed, we do nothing. + if ($current->getType($key) === $type && $indexed === $current->isIndex($key)) { + return; // if key exists, with same type and indexed, we do nothing. } } catch (FilesMetadataNotFoundException) { // if value does not exist, we keep on the writing of course } - $current->import([$key => ['type' => $type, 'indexed' => true]]); + $current->import([$key => ['type' => $type, 'indexed' => $indexed]]); $this->config->setAppValue('core', self::CONFIG_KEY, json_encode($current)); } diff --git a/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php b/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php index d628e468cdd..ff7dfcb8368 100644 --- a/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php +++ b/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php @@ -33,6 +33,7 @@ use OCP\Files\IRootFolder; use OCP\Files\NotPermittedException; use OCP\FilesMetadata\Event\MetadataLiveEvent; use OCP\FilesMetadata\IFilesMetadataManager; +use Psr\Log\LoggerInterface; /** * Simple background job, created when requested by an app during the @@ -47,6 +48,7 @@ class UpdateSingleMetadata extends QueuedJob { ITimeFactory $time, private IRootFolder $rootFolder, private FilesMetadataManager $filesMetadataManager, + private LoggerInterface $logger ) { parent::__construct($time); } @@ -60,7 +62,8 @@ class UpdateSingleMetadata extends QueuedJob { $file = array_shift($node); $this->filesMetadataManager->refreshMetadata($file, IFilesMetadataManager::PROCESS_BACKGROUND); } - } catch (NotPermittedException|NoUserException $e) { + } catch (\Exception $e) { + $this->logger->warning('issue while running UpdateSingleMetadata', ['exception' => $e, 'userId' => $userId, 'fileId' => $fileId]); } } } diff --git a/lib/private/FilesMetadata/Listener/MetadataDelete.php b/lib/private/FilesMetadata/Listener/MetadataDelete.php index 7f8fd035735..25c944475a9 100644 --- a/lib/private/FilesMetadata/Listener/MetadataDelete.php +++ b/lib/private/FilesMetadata/Listener/MetadataDelete.php @@ -30,6 +30,7 @@ use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Files\Events\Node\NodeDeletedEvent; use OCP\FilesMetadata\IFilesMetadataManager; +use Psr\Log\LoggerInterface; /** * Handle file deletion event and remove stored metadata related to the deleted file @@ -39,6 +40,7 @@ use OCP\FilesMetadata\IFilesMetadataManager; class MetadataDelete implements IEventListener { public function __construct( private IFilesMetadataManager $filesMetadataManager, + private LoggerInterface $logger ) { } @@ -56,6 +58,7 @@ class MetadataDelete implements IEventListener { $this->filesMetadataManager->deleteMetadata($nodeId); } } catch (Exception $e) { + $this->logger->warning('issue while running MetadataDelete', ['exception' => $e]); } } } diff --git a/lib/private/FilesMetadata/Listener/MetadataUpdate.php b/lib/private/FilesMetadata/Listener/MetadataUpdate.php index 64c8bb474b1..395a852e9e3 100644 --- a/lib/private/FilesMetadata/Listener/MetadataUpdate.php +++ b/lib/private/FilesMetadata/Listener/MetadataUpdate.php @@ -31,6 +31,7 @@ use OCP\EventDispatcher\IEventListener; use OCP\Files\Events\Node\NodeCreatedEvent; use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\FilesMetadata\IFilesMetadataManager; +use Psr\Log\LoggerInterface; /** * Handle file creation/modification events and initiate a new event related to the created/edited file. @@ -42,6 +43,7 @@ use OCP\FilesMetadata\IFilesMetadataManager; class MetadataUpdate implements IEventListener { public function __construct( private IFilesMetadataManager $filesMetadataManager, + private LoggerInterface $logger ) { } @@ -56,6 +58,7 @@ class MetadataUpdate implements IEventListener { try { $this->filesMetadataManager->refreshMetadata($event->getNode()); } catch (Exception $e) { + $this->logger->warning('issue while running MetadataUpdate', ['exception' => $e]); } } } diff --git a/lib/public/Files/Search/ISearchComparison.php b/lib/public/Files/Search/ISearchComparison.php index 068a7e4c699..68924d1e369 100644 --- a/lib/public/Files/Search/ISearchComparison.php +++ b/lib/public/Files/Search/ISearchComparison.php @@ -44,7 +44,7 @@ interface ISearchComparison extends ISearchOperator { * @return string * @since 12.0.0 */ - public function getType(); + public function getType(): string; /** * Get the name of the field to compare with @@ -54,8 +54,7 @@ interface ISearchComparison extends ISearchOperator { * @return string * @since 12.0.0 */ - public function getField(); - + public function getField(): string; /** * extra means data are not related to the main files table @@ -65,19 +64,11 @@ interface ISearchComparison extends ISearchOperator { */ public function getExtra(): string; - /** - * returns if data are 'extra' or not - * - * @return bool - * @since 28.0.0 - */ - public function isExtra(): bool; - /** * Get the value to compare the field with * * @return string|integer|\DateTime * @since 12.0.0 */ - public function getValue(); + public function getValue(): string|int|\DateTime; } diff --git a/lib/public/Files/Search/ISearchOrder.php b/lib/public/Files/Search/ISearchOrder.php index bcb927e73db..5b73e7b102c 100644 --- a/lib/public/Files/Search/ISearchOrder.php +++ b/lib/public/Files/Search/ISearchOrder.php @@ -57,15 +57,6 @@ interface ISearchOrder { */ public function getExtra(): string; - /** - * returns if data are 'extra' or not - * - * @return bool - * @since 28.0.0 - */ - public function isExtra(): bool; - - /** * Apply the sorting on 2 FileInfo objects * diff --git a/lib/public/FilesMetadata/IFilesMetadataManager.php b/lib/public/FilesMetadata/IFilesMetadataManager.php index 7ba8cac795a..1cd0fcb4125 100644 --- a/lib/public/FilesMetadata/IFilesMetadataManager.php +++ b/lib/public/FilesMetadata/IFilesMetadataManager.php @@ -38,10 +38,9 @@ use OCP\FilesMetadata\Model\IMetadataQuery; * @since 28.0.0 */ interface IFilesMetadataManager { - /** - * @since 28.0.0 - */ + /** @since 28.0.0 */ public const PROCESS_LIVE = 1; + /** @since 28.0.0 */ public const PROCESS_BACKGROUND = 2; /** @@ -128,10 +127,13 @@ interface IFilesMetadataManager { /** * initiate a metadata key with its type. * The call is mandatory before using the metadata property in a webdav request. + * It is not needed to only use this method when the app is enabled: the method can be + * called each time during the app loading as the metadata will only be initiated if not known * * @param string $key metadata key * @param string $type metadata type + * @param bool $indexed TRUE if metadata can be search * @since 28.0.0 */ - public function initMetadataIndex(string $key, string $type): void; + public function initMetadata(string $key, string $type, bool $indexed): void; } diff --git a/lib/public/FilesMetadata/Model/IMetadataQuery.php b/lib/public/FilesMetadata/Model/IMetadataQuery.php index 3e68b47f822..d3f55ce6cce 100644 --- a/lib/public/FilesMetadata/Model/IMetadataQuery.php +++ b/lib/public/FilesMetadata/Model/IMetadataQuery.php @@ -31,6 +31,7 @@ namespace OCP\FilesMetadata\Model; * @since 28.0.0 */ interface IMetadataQuery { + /** @since 28.0.0 */ public const EXTRA = 'metadata'; /** -- cgit v1.2.3