Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sabre/Album/AlbumsHome.php')
-rw-r--r--lib/Sabre/Album/AlbumsHome.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/Sabre/Album/AlbumsHome.php b/lib/Sabre/Album/AlbumsHome.php
index 1c070b59..a2bc2fe7 100644
--- a/lib/Sabre/Album/AlbumsHome.php
+++ b/lib/Sabre/Album/AlbumsHome.php
@@ -39,6 +39,11 @@ class AlbumsHome implements ICollection {
private IRootFolder $rootFolder;
private Folder $userFolder;
+ /**
+ * @var AlbumRoot[]
+ */
+ private ?array $children = null;
+
public function __construct(
array $principalInfo,
AlbumMapper $albumMapper,
@@ -52,6 +57,9 @@ class AlbumsHome implements ICollection {
$this->userFolder = $rootFolder->getUserFolder($user->getUID());
}
+ /**
+ * @return never
+ */
public function delete() {
throw new Forbidden();
}
@@ -60,6 +68,9 @@ class AlbumsHome implements ICollection {
return 'albums';
}
+ /**
+ * @return never
+ */
public function setName($name) {
throw new Forbidden('Permission denied to rename this folder');
}
@@ -68,6 +79,9 @@ class AlbumsHome implements ICollection {
throw new Forbidden('Not allowed to create files in this folder');
}
+ /**
+ * @return void
+ */
public function createDirectory($name) {
$uid = $this->user->getUID();
$this->albumMapper->create($uid, $name);
@@ -87,10 +101,14 @@ class AlbumsHome implements ICollection {
* @return AlbumRoot[]
*/
public function getChildren(): array {
- $folders = $this->albumMapper->getForUserWithFiles($this->user->getUID());
- return array_map(function (AlbumWithFiles $folder) {
- return new AlbumRoot($this->albumMapper, $folder, $this->rootFolder, $this->userFolder, $this->user);
- }, $folders);
+ if ($this->children === null) {
+ $folders = $this->albumMapper->getForUserWithFiles($this->user->getUID());
+ $this->children = array_map(function (AlbumWithFiles $folder) {
+ return new AlbumRoot($this->albumMapper, $folder, $this->rootFolder, $this->userFolder, $this->user);
+ }, $folders);
+ }
+
+ return $this->children;
}
public function childExists($name): bool {