diff options
author | Louis Chemineau <louis@chmn.me> | 2023-11-21 11:36:41 +0100 |
---|---|---|
committer | Louis <louis@chmn.me> | 2023-11-21 13:52:31 +0100 |
commit | b63ddc73a27febab7a19353a68c3bdce723d5bba (patch) | |
tree | 61a451d58a3b2638aa74b11c1d9db3a914652cd7 /lib | |
parent | f74084cd3de6e199fc10a66d2072abfac27e179d (diff) | |
download | nextcloud-server-b63ddc73a27febab7a19353a68c3bdce723d5bba.tar.gz nextcloud-server-b63ddc73a27febab7a19353a68c3bdce723d5bba.zip |
Listen to cache event when deleting metadata
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/FilesMetadata/FilesMetadataManager.php | 4 | ||||
-rw-r--r-- | lib/private/FilesMetadata/Listener/MetadataDelete.php | 11 |
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/private/FilesMetadata/FilesMetadataManager.php b/lib/private/FilesMetadata/FilesMetadataManager.php index 187eed67768..28498af4ab0 100644 --- a/lib/private/FilesMetadata/FilesMetadataManager.php +++ b/lib/private/FilesMetadata/FilesMetadataManager.php @@ -37,7 +37,7 @@ use OCP\DB\Exception; use OCP\DB\Exception as DBException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Events\Node\NodeDeletedEvent; +use OCP\Files\Cache\CacheEntryRemovedEvent; use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\Files\InvalidPathException; use OCP\Files\Node; @@ -305,6 +305,6 @@ class FilesMetadataManager implements IFilesMetadataManager { */ public static function loadListeners(IEventDispatcher $eventDispatcher): void { $eventDispatcher->addServiceListener(NodeWrittenEvent::class, MetadataUpdate::class); - $eventDispatcher->addServiceListener(NodeDeletedEvent::class, MetadataDelete::class); + $eventDispatcher->addServiceListener(CacheEntryRemovedEvent::class, MetadataDelete::class); } } diff --git a/lib/private/FilesMetadata/Listener/MetadataDelete.php b/lib/private/FilesMetadata/Listener/MetadataDelete.php index 25c944475a9..d950c2cea5f 100644 --- a/lib/private/FilesMetadata/Listener/MetadataDelete.php +++ b/lib/private/FilesMetadata/Listener/MetadataDelete.php @@ -28,14 +28,14 @@ namespace OC\FilesMetadata\Listener; use Exception; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\Files\Events\Node\NodeDeletedEvent; +use OCP\Files\Cache\CacheEntryRemovedEvent; use OCP\FilesMetadata\IFilesMetadataManager; use Psr\Log\LoggerInterface; /** * Handle file deletion event and remove stored metadata related to the deleted file * - * @template-implements IEventListener<NodeDeletedEvent> + * @template-implements IEventListener<CacheEntryRemovedEvent> */ class MetadataDelete implements IEventListener { public function __construct( @@ -44,16 +44,13 @@ class MetadataDelete implements IEventListener { ) { } - /** - * @param Event $event - */ public function handle(Event $event): void { - if (!($event instanceof NodeDeletedEvent)) { + if (!($event instanceof CacheEntryRemovedEvent)) { return; } try { - $nodeId = (int)$event->getNode()->getId(); + $nodeId = $event->getFileId(); if ($nodeId > 0) { $this->filesMetadataManager->deleteMetadata($nodeId); } |