diff --git a/lib/Dav/Faces/FacePhoto.php b/lib/Dav/Faces/FacePhoto.php index bf70248c..98af9d63 100644 --- a/lib/Dav/Faces/FacePhoto.php +++ b/lib/Dav/Faces/FacePhoto.php @@ -70,9 +70,8 @@ public function put($data): never { public function getFile() : File { if ($this->file === null) { - $nodes = $this->userFolder->getById($this->faceDetection->getFileId()); - $node = current($nodes); - if ($node) { + $node = $this->userFolder->getFirstNodeById($this->faceDetection->getFileId()); + if ($node !== null) { if ($node instanceof File) { return $this->file = $node; } else { diff --git a/lib/Dav/Faces/FaceRoot.php b/lib/Dav/Faces/FaceRoot.php index ec53bbb6..97b0d862 100644 --- a/lib/Dav/Faces/FaceRoot.php +++ b/lib/Dav/Faces/FaceRoot.php @@ -90,9 +90,10 @@ public function createFile($name, $data = null): never { public function getChildren(): array { if (count($this->children) === 0) { $detections = $this->detectionMapper->findByClusterId($this->cluster->getId()); - $detectionsWithFile = array_filter($detections, fn (FaceDetection $detection): bool => current($this->rootFolder->getUserFolder($this->user->getUID())->getById($detection->getFileId())) !== false); - $this->children = array_map(function (FaceDetection $detection) { - return new FacePhoto($this->detectionMapper, $detection, $this->rootFolder->getUserFolder($this->user->getUID()), $this->tagManager, $this->previewManager); + $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); + $detectionsWithFile = array_filter($detections, fn (FaceDetection $detection): bool => $userFolder->getFirstNodeById($detection->getFileId()) !== null); + $this->children = array_map(function (FaceDetection $detection) use ($userFolder) { + return new FacePhoto($this->detectionMapper, $detection, $userFolder, $this->tagManager, $this->previewManager); }, $detectionsWithFile); } return $this->children; diff --git a/lib/Dav/Faces/UnassignedFacesHome.php b/lib/Dav/Faces/UnassignedFacesHome.php index ad2be890..a1d491d4 100644 --- a/lib/Dav/Faces/UnassignedFacesHome.php +++ b/lib/Dav/Faces/UnassignedFacesHome.php @@ -102,10 +102,17 @@ public function getChildren(): array { } $detections = $this->faceDetectionMapper->findRejectedByUserId($this->user->getUID()); - $detectionsWithFile = array_filter($detections, fn (FaceDetection $detection): bool => current($this->rootFolder->getUserFolder($this->user->getUID())->getById($detection->getFileId())) !== false); + $userFolder = $this->rootFolder->getUserFolder($this->user->getUID()); + $detectionsWithFile = array_filter($detections, fn (FaceDetection $detection): bool => + $userFolder->getFirstNodeById($detection->getFileId()) !== null); $this->children = array_values(array_map(fn (FaceDetection $detection): UnassignedFacePhoto - => new UnassignedFacePhoto($this->faceDetectionMapper, $detection, $this->rootFolder->getUserFolder($this->user->getUID()), $this->tagManager, $this->previewManager), - $detectionsWithFile)); + => new UnassignedFacePhoto( + $this->faceDetectionMapper, + $detection, + $this->rootFolder->getUserFolder($this->user->getUID()), + $this->tagManager, + $this->previewManager + ), $detectionsWithFile)); return $this->children; }