aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV/PhotoCache.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/CardDAV/PhotoCache.php')
-rw-r--r--apps/dav/lib/CardDAV/PhotoCache.php25
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php
index 2f1999b6b1c..03c71f7e4a3 100644
--- a/apps/dav/lib/CardDAV/PhotoCache.php
+++ b/apps/dav/lib/CardDAV/PhotoCache.php
@@ -1,10 +1,13 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+
namespace OCA\DAV\CardDAV;
+use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
@@ -19,6 +22,7 @@ use Sabre\VObject\Property\Binary;
use Sabre\VObject\Reader;
class PhotoCache {
+ private ?IAppData $photoCacheAppData = null;
/** @var array */
public const ALLOWED_CONTENT_TYPES = [
@@ -30,12 +34,9 @@ class PhotoCache {
'image/avif' => 'avif',
];
- /**
- * PhotoCache constructor.
- */
public function __construct(
- protected IAppData $appData,
- protected LoggerInterface $logger,
+ private IAppDataFactory $appDataFactory,
+ private LoggerInterface $logger,
) {
}
@@ -142,13 +143,12 @@ class PhotoCache {
private function getFolder(int $addressBookId, string $cardUri, bool $createIfNotExists = true): ISimpleFolder {
$hash = md5($addressBookId . ' ' . $cardUri);
try {
- return $this->appData->getFolder($hash);
+ return $this->getPhotoCacheAppData()->getFolder($hash);
} catch (NotFoundException $e) {
if ($createIfNotExists) {
- return $this->appData->newFolder($hash);
- } else {
- throw $e;
+ return $this->getPhotoCacheAppData()->newFolder($hash);
}
+ throw $e;
}
}
@@ -265,4 +265,11 @@ class PhotoCache {
// that's OK, nothing to do
}
}
+
+ private function getPhotoCacheAppData(): IAppData {
+ if ($this->photoCacheAppData === null) {
+ $this->photoCacheAppData = $this->appDataFactory->get('dav-photocache');
+ }
+ return $this->photoCacheAppData;
+ }
}