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;
*/
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);
}
}
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(
) {
}
- /**
- * @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);
}