summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2019-04-30 09:25:45 +0200
committerGitHub <noreply@github.com>2019-04-30 09:25:45 +0200
commite727e01701b685595a8026d3bab86e0f50f457f0 (patch)
tree2eacae1334b653031689882a126bbbe3b7c70014
parent4fd2cbeb94faea75d9d14be3939a7d6bce2d88cf (diff)
parent3c78116cf8b6b23c74f3270162471f10eb4f939e (diff)
downloadnextcloud-server-e727e01701b685595a8026d3bab86e0f50f457f0.tar.gz
nextcloud-server-e727e01701b685595a8026d3bab86e0f50f457f0.zip
Merge pull request #15290 from nextcloud/fix/8635/mdkir-handling+no-create-to-delete
take return of mkdir into consideration; photocache to not create a folder for deletion
-rw-r--r--apps/dav/lib/CardDAV/PhotoCache.php22
-rw-r--r--lib/private/Files/Node/Folder.php4
2 files changed, 18 insertions, 8 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
+ }
}
}
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index a9b443ce52e..ebf67e47a21 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -158,7 +158,9 @@ class Folder extends Node implements \OCP\Files\Folder {
$nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath);
$this->root->emit('\OC\Files', 'preWrite', array($nonExisting));
$this->root->emit('\OC\Files', 'preCreate', array($nonExisting));
- $this->view->mkdir($fullPath);
+ if(!$this->view->mkdir($fullPath)) {
+ throw new NotPermittedException('Could not create folder');
+ }
$node = new Folder($this->root, $this->view, $fullPath);
$this->root->emit('\OC\Files', 'postWrite', array($node));
$this->root->emit('\OC\Files', 'postCreate', array($node));