diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2023-11-07 12:43:01 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2023-11-07 12:43:08 -0100 |
commit | f497d8b6e5a42635ec181dfeda404862ee4c8e3d (patch) | |
tree | e6cd926b6f7ab4d9762f0312ad8962c78aaf1309 /lib/private/FilesMetadata | |
parent | e62e9e3dbf1a2573554b1a9eabbf5b59b652dae6 (diff) | |
download | nextcloud-server-f497d8b6e5a42635ec181dfeda404862ee4c8e3d.tar.gz nextcloud-server-f497d8b6e5a42635ec181dfeda404862ee4c8e3d.zip |
IFilesMetadata
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/private/FilesMetadata')
4 files changed, 15 insertions, 5 deletions
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]); } } } |