diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php index eed11f1e9397a4f2ac356fde038cf7560e6a5454..8632fd45f2231a2b2811f81a0d62d4f02246c2df 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 a9b443ce52e77b402ec2b54066f960384a226013..ebf67e47a2173ba22295ea7317ae7a57bed6ebad 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));