[CalendarServer-changes] [14402] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 11 11:55:49 PST 2015
Revision: 14402
http://trac.calendarserver.org//changeset/14402
Author: sagen at apple.com
Date: 2015-02-11 11:55:49 -0800 (Wed, 11 Feb 2015)
Log Message:
-----------
sync-token DAV property contains config component if enabled
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/config.py
CalendarServer/trunk/twistedcaldav/resource.py
CalendarServer/trunk/twistedcaldav/test/test_resource.py
Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py 2015-02-10 22:49:34 UTC (rev 14401)
+++ CalendarServer/trunk/twistedcaldav/config.py 2015-02-11 19:55:49 UTC (rev 14402)
@@ -370,7 +370,18 @@
self._cachedSyncToken = None
+ def joinToken(self, dataToken):
+ """
+ Joins the config sync token with the dataToken. If EnableConfigSyncToken
+ is False, the original dataToken is just returned
+ """
+ if self.EnableConfigSyncToken:
+ configToken = self.syncToken()
+ return "{}/{}".format(dataToken, configToken)
+ else:
+ return dataToken
+
def mergeData(oldData, newData):
"""
Merge two ConfigDict objects; oldData will be updated with all the keys
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2015-02-10 22:49:34 UTC (rev 14401)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2015-02-11 19:55:49 UTC (rev 14402)
@@ -1194,6 +1194,8 @@
client_data_token = client_token
current_token = (yield self.getSyncToken())
+ if "/" in current_token:
+ current_token = current_token.split("/")[0]
current_uuid, current_revision = current_token[6:].split("_", 1)
current_revision = int(current_revision)
@@ -1252,7 +1254,9 @@
"""
internal_token = (yield self.getInternalSyncToken())
- returnValue("data:,%s" % (internal_token,))
+ internal_token = "data:,%s" % (internal_token,)
+ token = config.joinToken(internal_token)
+ returnValue(token)
def getInternalSyncToken(self):
@@ -2058,12 +2062,25 @@
def _mergeSyncTokens(self, hometoken, notificationtoken):
"""
Merge two sync tokens, choosing the higher revision number of the two,
- but keeping the home resource-id intact.
+ but keeping the home resource-id intact. If the config portion of
+ the token is present, it is also kept intact.
"""
+ if "/" in hometoken:
+ hometoken, configtoken = hometoken.split("/")
+ else:
+ configtoken = None
+
+ if "/" in notificationtoken:
+ notificationtoken = notificationtoken.split("/")[0]
+
homekey, homerev = hometoken.split("_", 1)
notrev = notificationtoken.split("_", 1)[1]
if int(notrev) > int(homerev):
hometoken = "%s_%s" % (homekey, notrev,)
+
+ if configtoken:
+ hometoken = "{}/{}".format(hometoken, configtoken)
+
return hometoken
Modified: CalendarServer/trunk/twistedcaldav/test/test_resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_resource.py 2015-02-10 22:49:34 UTC (rev 14401)
+++ CalendarServer/trunk/twistedcaldav/test/test_resource.py 2015-02-11 19:55:49 UTC (rev 14402)
@@ -111,7 +111,13 @@
self.assertTrue(('http://calendarserver.org/ns/', 'getctag') in resource.liveProperties())
+ def test_commonHomeResourceMergeSyncToken(self):
+ resource = CommonHomeResource(None, None, None, StubHome())
+ self.assertEquals(resource._mergeSyncTokens("1_2/A", "1_3/A"), "1_3/A")
+ self.assertEquals(resource._mergeSyncTokens("1_2", "1_3"), "1_3")
+ self.assertEquals(resource._mergeSyncTokens("1_4", "1_3"), "1_4")
+
class OwnershipTests(TestCase):
"""
L{CalDAVResource.isOwner} determines if the authenticated principal of the
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150211/101c078c/attachment.html>
More information about the calendarserver-changes
mailing list