From 4b2a77b1ff48b4d6fa8e0865df173e5b774214e9 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 18 Mar 2026 09:46:54 -0400 Subject: [PATCH 1/6] chore(trashbin): refactor deprecated abortOperation to use AbortedEventException Signed-off-by: Josh --- .../lib/Events/BeforeNodeRestoredEvent.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/files_trashbin/lib/Events/BeforeNodeRestoredEvent.php b/apps/files_trashbin/lib/Events/BeforeNodeRestoredEvent.php index 0bc6b37c35b95..405d9b6396eda 100644 --- a/apps/files_trashbin/lib/Events/BeforeNodeRestoredEvent.php +++ b/apps/files_trashbin/lib/Events/BeforeNodeRestoredEvent.php @@ -8,7 +8,7 @@ */ namespace OCA\Files_Trashbin\Events; -use Exception; +use OCP\Exceptions\AbortedEventException; use OCP\Files\Events\Node\AbstractNodesEvent; use OCP\Files\Node; @@ -25,15 +25,10 @@ public function __construct( } /** - * @return never + * @since 28.0.0 + * @deprecated 29.0.0 - use OCP\Exceptions\AbortedEventException instead */ public function abortOperation(?\Throwable $ex = null) { - $this->stopPropagation(); - $this->run = false; - if ($ex !== null) { - throw $ex; - } else { - throw new Exception('Operation aborted'); - } + throw new AbortedEventException($ex?->getMessage() ?? 'Operation aborted'); } } From 23569000a864a31d444b1af15cb8a8c0bec6c908 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 18 Mar 2026 09:52:41 -0400 Subject: [PATCH 2/6] chore(trashbin): switch SyncLivePhotosListener to AbortedEventException Signed-off-by: Josh --- .../lib/Listeners/SyncLivePhotosListener.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php b/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php index 2cb3a94aa1dc8..8b449e419fe23 100644 --- a/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php +++ b/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php @@ -14,6 +14,7 @@ use OCA\Files_Trashbin\Trash\ITrashManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\Exceptions\AbortedEventException; use OCP\Files\Folder; use OCP\Files\Node; use OCP\Files\NotFoundException; @@ -76,7 +77,7 @@ private function handleRestore(BeforeNodeRestoredEvent $event, Node $peerFile): unset($this->pendingRestores[$peerFile->getId()]); return; } else { - $event->abortOperation(new NotPermittedException('Cannot restore the video part of a live photo')); + throw new AbortedEventException('Cannot restore the video part of a live photo'); } } else { $user = $this->userSession?->getUser(); @@ -94,14 +95,14 @@ private function handleRestore(BeforeNodeRestoredEvent $event, Node $peerFile): $trashItem = $this->getTrashItem($trashRoot, $peerFile->getInternalPath()); if ($trashItem === null) { - $event->abortOperation(new NotFoundException("Couldn't find peer file in trashbin")); + throw new AbortedEventException('Could not find peer file in trashbin'); } $this->pendingRestores[$sourceFile->getId()] = true; try { $this->trashManager->restoreItem($trashItem); } catch (\Throwable $ex) { - $event->abortOperation($ex); + throw new AbortedEventException($ex->getMessage()); } } } From bd0784e05619d6f85682ec34b0c6f729e1f98d76 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 18 Mar 2026 09:55:33 -0400 Subject: [PATCH 3/6] refactor(Trashbin): switch to AbortedEventException usage in restore Signed-off-by: Josh --- apps/files_trashbin/lib/Trashbin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index d578e14238672..e493e2a6a2bf3 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -515,7 +515,11 @@ public static function restore($file, $filename, $timestamp) { $run = true; $event = new BeforeNodeRestoredEvent($sourceNode, $targetNode, $run); $dispatcher = Server::get(IEventDispatcher::class); - $dispatcher->dispatchTyped($event); + try { + $dispatcher->dispatchTyped($event); + } catch (AbortedEventException) { + $run = false; + } if (!$run) { return false; From 5f658d9eaefe9e7fd3a44b760cb911a4e4fe21d3 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 18 Mar 2026 12:02:19 -0400 Subject: [PATCH 4/6] chore(Trashbin): add AbortedEventException use Signed-off-by: Josh --- apps/files_trashbin/lib/Trashbin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index e493e2a6a2bf3..12af607b536ea 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -26,6 +26,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Command\IBus; use OCP\Config\IUserConfig; +use OCP\Exceptions\AbortedEventException; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventListener; From e53c124ecc76b01164e1004a6f2492a9eb7dc87f Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 18 Mar 2026 12:50:46 -0400 Subject: [PATCH 5/6] chore(trashbin): drop unused use statements from SyncLivePhotosListener Signed-off-by: Josh --- apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php b/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php index 8b449e419fe23..decd34fbdd5d7 100644 --- a/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php +++ b/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php @@ -17,8 +17,6 @@ use OCP\Exceptions\AbortedEventException; use OCP\Files\Folder; use OCP\Files\Node; -use OCP\Files\NotFoundException; -use OCP\Files\NotPermittedException; use OCP\IUserSession; /** From 8bd63c5fe23e21fa36b15aa57eaa2aa9d342fc0e Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 18 Mar 2026 12:51:34 -0400 Subject: [PATCH 6/6] chore(Trashbin): hello lint Signed-off-by: Josh --- apps/files_trashbin/lib/Trashbin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 12af607b536ea..ea9d7496c5bbb 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -26,10 +26,10 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Command\IBus; use OCP\Config\IUserConfig; -use OCP\Exceptions\AbortedEventException; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventListener; +use OCP\Exceptions\AbortedEventException; use OCP\Files\Events\Node\BeforeNodeDeletedEvent; use OCP\Files\File; use OCP\Files\Folder;