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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-04-29 17:15:07 +0300
committerBackportbot <backportbot-noreply@rullzer.com>2019-04-30 10:26:41 +0300
commit2f0055455d580e62bda696f7184a8cd9d935ce30 (patch)
tree95cbd672316621dd0148eef8ce8bfceff86790b4 /apps
parentaa91b0ab3cf59fd2f6ae2b865fd62059b803b145 (diff)
do not create folder just to delete it afterwards
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CardDAV/PhotoCache.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php
index eed11f1e939..8632fd45f22 100644
--- a/apps/dav/lib/CardDAV/PhotoCache.php
+++ b/apps/dav/lib/CardDAV/PhotoCache.php
@@ -167,16 +167,19 @@ class PhotoCache {
}
/**
- * @param int $addressBookId
- * @param string $cardUri
- * @return ISimpleFolder
+ * @throws NotFoundException
+ * @throws NotPermittedException
*/
- private function getFolder($addressBookId, $cardUri) {
+ private function getFolder(int $addressBookId, string $cardUri, bool $createIfNotExists = true): ISimpleFolder {
$hash = md5($addressBookId . ' ' . $cardUri);
try {
return $this->appData->getFolder($hash);
} catch (NotFoundException $e) {
- return $this->appData->newFolder($hash);
+ if($createIfNotExists) {
+ return $this->appData->newFolder($hash);
+ } else {
+ throw $e;
+ }
}
}
@@ -271,9 +274,14 @@ class PhotoCache {
/**
* @param int $addressBookId
* @param string $cardUri
+ * @throws NotPermittedException
*/
public function delete($addressBookId, $cardUri) {
- $folder = $this->getFolder($addressBookId, $cardUri);
- $folder->delete();
+ try {
+ $folder = $this->getFolder($addressBookId, $cardUri, false);
+ $folder->delete();
+ } catch (NotFoundException $e) {
+ // that's OK, nothing to do
+ }
}
}