diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-05-03 15:11:26 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-05-08 11:20:49 +0200 |
commit | 3ab53d000f5e5e9d35e459109fc61c2ef936752d (patch) | |
tree | 8d8433ea2b2b72d18e746a232ee96556cc71dfb7 /apps/dav/lib/CardDAV | |
parent | 34d97aa51c5e7ddb638aeb105a590ae159a34abe (diff) | |
download | nextcloud-server-3ab53d000f5e5e9d35e459109fc61c2ef936752d.tar.gz nextcloud-server-3ab53d000f5e5e9d35e459109fc61c2ef936752d.zip |
Clear cache on vcard change/delete
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib/CardDAV')
-rw-r--r-- | apps/dav/lib/CardDAV/ImageExportPlugin.php | 4 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/PhotoCache.php | 22 |
2 files changed, 18 insertions, 8 deletions
diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php index 9d5eba453fb..fd9223c855b 100644 --- a/apps/dav/lib/CardDAV/ImageExportPlugin.php +++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php @@ -103,14 +103,12 @@ class ImageExportPlugin extends ServerPlugin { /** @var AddressBook $addressbook */ $addressbook = $this->server->tree->getNodeForPath($addressbookpath); - $hash = md5($addressbook->getResourceId() . $node->getName()); - $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); $response->setHeader('Etag', $node->getETag() ); $response->setHeader('Pragma', 'public'); try { - $file = $this->cache->get($hash, $size, $node); + $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node); $response->setHeader('Content-Type', $file->getMimeType()); $response->setHeader('Content-Disposition', 'inline'); $response->setStatus(200); diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php index 29c45debdef..c9625914263 100644 --- a/apps/dav/lib/CardDAV/PhotoCache.php +++ b/apps/dav/lib/CardDAV/PhotoCache.php @@ -26,15 +26,16 @@ class PhotoCache { } /** - * @param string $hash + * @param int $addressBookId + * @param string $cardUri * @param int $size * @param Card $card * * @return ISimpleFile * @throws NotFoundException */ - public function get($hash, $size, Card $card) { - $folder = $this->getFolder($hash); + public function get($addressBookId, $cardUri, $size, Card $card) { + $folder = $this->getFolder($addressBookId, $cardUri); if ($this->isEmpty($folder)) { $this->init($folder, $card); @@ -132,10 +133,12 @@ class PhotoCache { /** - * @param $hash + * @param int $addressBookId + * @param string $cardUri * @return ISimpleFolder */ - private function getFolder($hash) { + private function getFolder($addressBookId, $cardUri) { + $hash = md5($addressBookId . ' ' . $cardUri); try { return $this->appData->getFolder($hash); } catch (NotFoundException $e) { @@ -231,4 +234,13 @@ class PhotoCache { } return ''; } + + /** + * @param int $addressBookId + * @param string $cardUri + */ + public function delete($addressBookId, $cardUri) { + $folder = $this->getFolder($addressBookId, $cardUri); + $folder->delete(); + } } |