diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-07 14:54:26 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-07-09 11:43:58 +0200 |
commit | aab646a9d0f67f42fe8eb3398e6b4b726c501585 (patch) | |
tree | 1dc26ff116beb28a3b8f8a37136e73610cb33f2c /apps/dav/tests | |
parent | 09b9f94c38dda015412cebf2cc8f7c7100001a67 (diff) | |
download | nextcloud-server-aab646a9d0f67f42fe8eb3398e6b4b726c501585.tar.gz nextcloud-server-aab646a9d0f67f42fe8eb3398e6b4b726c501585.zip |
Update system addressbook card only when there was a change based on a cached etag
Due to our old and new hook system the card dav backend listens to old and new hooks. This triggers this code multiple times and always causes an update. With this change we cache the etag during a request and only trigger the update if the etag has changed. This does not catches all not needed updates, but it does not need another round trip to the database and still covers most cases where multiple attributes are updated during one single request.
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/CardDavBackendTest.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index c32aad5a056..0e507bc6b3d 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -253,7 +253,7 @@ class CardDavBackendTest extends TestCase { $uri = $this->getUniqueID('card'); // updateProperties is expected twice, once for createCard and once for updateCard $backend->expects($this->at(0))->method('updateProperties')->with($bookId, $uri, $this->vcardTest0); - $backend->expects($this->at(1))->method('updateProperties')->with($bookId, $uri, $this->vcardTest0); + $backend->expects($this->at(1))->method('updateProperties')->with($bookId, $uri, $this->vcardTest1); // Expect event $this->dispatcher->expects($this->at(0)) @@ -288,13 +288,13 @@ class CardDavBackendTest extends TestCase { ->with('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) { return $e->getArgument('addressBookId') === $bookId && $e->getArgument('cardUri') === $uri && - $e->getArgument('cardData') === $this->vcardTest0; + $e->getArgument('cardData') === $this->vcardTest1; })); // update the card - $backend->updateCard($bookId, $uri, $this->vcardTest0); + $backend->updateCard($bookId, $uri, $this->vcardTest1); $card = $backend->getCard($bookId, $uri); - $this->assertEquals($this->vcardTest0, $card['carddata']); + $this->assertEquals($this->vcardTest1, $card['carddata']); // Expect event $this->dispatcher->expects($this->at(0)) |