aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/FilesMetadata/Listener
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2023-11-21 11:36:41 +0100
committerLouis <louis@chmn.me>2023-11-21 13:52:31 +0100
commitb63ddc73a27febab7a19353a68c3bdce723d5bba (patch)
tree61a451d58a3b2638aa74b11c1d9db3a914652cd7 /lib/private/FilesMetadata/Listener
parentf74084cd3de6e199fc10a66d2072abfac27e179d (diff)
downloadnextcloud-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/private/FilesMetadata/Listener')
-rw-r--r--lib/private/FilesMetadata/Listener/MetadataDelete.php11
1 files changed, 4 insertions, 7 deletions
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);
}