diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 4a1dc328a..f3e9fbc37 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -28,12 +28,12 @@ use OCA\DAV\Events\SabrePluginAuthInitEvent; use OCA\Photos\Listener\SabrePluginAuthInitListener; use OCA\DAV\Connector\Sabre\Principal; -use OCA\Photos\Listener\CacheEntryRemovedListener; +use OCA\Photos\Listener\NodeDeletedListener; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; -use OCP\Files\Cache\CacheEntryRemovedEvent; +use OCP\Files\Events\Node\NodeDeletedEvent; class Application extends App implements IBootstrap { public const APP_ID = 'photos'; @@ -65,7 +65,7 @@ public function __construct() { public function register(IRegistrationContext $context): void { /** Register $principalBackend for the DAV collection */ $context->registerServiceAlias('principalBackend', Principal::class); - $context->registerEventListener(CacheEntryRemovedEvent::class, CacheEntryRemovedListener::class); + $context->registerEventListener(NodeDeletedEvent::class, NodeDeletedListener::class); $context->registerEventListener(SabrePluginAuthInitEvent::class, SabrePluginAuthInitListener::class); } diff --git a/lib/Listener/CacheEntryRemovedListener.php b/lib/Listener/NodeDeletedListener.php similarity index 70% rename from lib/Listener/CacheEntryRemovedListener.php rename to lib/Listener/NodeDeletedListener.php index 2455cac7d..96bcdd2aa 100644 --- a/lib/Listener/CacheEntryRemovedListener.php +++ b/lib/Listener/NodeDeletedListener.php @@ -5,9 +5,9 @@ use OCA\Photos\Album\AlbumMapper; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\Files\Cache\CacheEntryRemovedEvent; +use OCP\Files\Events\Node\NodeDeletedEvent; -class CacheEntryRemovedListener implements IEventListener { +class NodeDeletedListener implements IEventListener { private AlbumMapper $albumMapper; public function __construct(AlbumMapper $albumMapper) { @@ -15,16 +15,16 @@ public function __construct(AlbumMapper $albumMapper) { } public function handle(Event $event): void { - if (!($event instanceof CacheEntryRemovedEvent)) { + if (!($event instanceof NodeDeletedEvent)) { return; } try { // Remove node from all albums containing it. - $albums = $this->albumMapper->getForFile($event->getFileId()); + $albums = $this->albumMapper->getForFile($event->getNode()->getId()); foreach ($albums as $album) { - $this->albumMapper->removeFile($album->getId(), $event->getFileId()); + $this->albumMapper->removeFile($album->getId(), $event->getNode()->getId()); } } catch(\Throwable $ex) { // If an error occur, return silently as we don't want to block the rest of the deletion process.