From e7a7b4a40184dc3da2c83e858c820625f660e48e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 9 Feb 2024 09:54:52 +0100 Subject: perf: switch places that always use the first getById result to getFirstNodeById Signed-off-by: Robin Appelman --- apps/files_trashbin/lib/Trash/LegacyTrashBackend.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'apps/files_trashbin/lib') diff --git a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php index 3e749169ad2..ada42dbe857 100644 --- a/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php +++ b/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php @@ -28,6 +28,7 @@ use OCA\Files_Trashbin\Helper; use OCA\Files_Trashbin\Storage; use OCA\Files_Trashbin\Trashbin; use OCP\Files\FileInfo; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; @@ -121,11 +122,11 @@ class LegacyTrashBackend implements ITrashBackend { try { $userFolder = $this->rootFolder->getUserFolder($user->getUID()); $trash = $userFolder->getParent()->get('files_trashbin/files'); - $trashFiles = $trash->getById($fileId); - if (!$trashFiles) { + if ($trash instanceof Folder) { + return $trash->getFirstNodeById($fileId); + } else { return null; } - return $trashFiles ? array_pop($trashFiles) : null; } catch (NotFoundException $e) { return null; } -- cgit v1.2.3