[CalendarServer-changes] [6709] CalendarServer/trunk/txdav/common/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 22 18:45:52 PST 2010
Revision: 6709
http://trac.macosforge.org/projects/calendarserver/changeset/6709
Author: cdaboo at apple.com
Date: 2010-12-22 18:45:47 -0800 (Wed, 22 Dec 2010)
Log Message:
-----------
Make sure shared collection removal only changes sync token for that collection and not the original.
Modified Paths:
--------------
CalendarServer/trunk/txdav/common/datastore/sql.py
CalendarServer/trunk/txdav/common/datastore/sql_legacy.py
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2010-12-23 02:44:55 UTC (rev 6708)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2010-12-23 02:45:47 UTC (rev 6709)
@@ -1245,7 +1245,7 @@
@inlineCallbacks
- def _deletedSyncToken(self):
+ def _deletedSyncToken(self, sharedRemoval=False):
# Remove all child entries
yield self._txn.execSQL("""
@@ -1255,17 +1255,29 @@
[self._home._resourceID, self._resourceID,]
)
- # Then adjust collection entry to deleted state (do this for all entries with this collection's
- # resource-id so that we deal with direct shares which are not normally removed through an unshare
- yield self._txn.execSQL("""
- update %(name)s
- set (%(column_RESOURCE_ID)s, %(column_REVISION)s, %(column_DELETED)s)
- = (null, nextval('%(sequence)s'), TRUE)
- where %(column_RESOURCE_ID)s = %%s and %(column_RESOURCE_NAME)s is null
- returning %(column_REVISION)s
- """ % self._revisionsTable,
- [self._resourceID,]
- )
+ # If this is a share being removed then we only mark this one specific home/resource-id as being deleted.
+ # On the other hand, if it is a non-shared collection, then we need to mark all collections
+ # with the resource-id as being deleted to account for direct shares.
+ if sharedRemoval:
+ yield self._txn.execSQL("""
+ update %(name)s
+ set (%(column_RESOURCE_ID)s, %(column_REVISION)s, %(column_DELETED)s)
+ = (null, nextval('%(sequence)s'), TRUE)
+ where %(column_HOME_RESOURCE_ID)s = %%s and %(column_RESOURCE_ID)s = %%s and %(column_RESOURCE_NAME)s is null
+ returning %(column_REVISION)s
+ """ % self._revisionsTable,
+ [self._home._resourceID, self._resourceID,]
+ )
+ else:
+ yield self._txn.execSQL("""
+ update %(name)s
+ set (%(column_RESOURCE_ID)s, %(column_REVISION)s, %(column_DELETED)s)
+ = (null, nextval('%(sequence)s'), TRUE)
+ where %(column_RESOURCE_ID)s = %%s and %(column_RESOURCE_NAME)s is null
+ returning %(column_REVISION)s
+ """ % self._revisionsTable,
+ [self._resourceID,]
+ )
self._syncTokenRevision = None
Modified: CalendarServer/trunk/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_legacy.py 2010-12-23 02:44:55 UTC (rev 6708)
+++ CalendarServer/trunk/txdav/common/datastore/sql_legacy.py 2010-12-23 02:45:47 UTC (rev 6709)
@@ -584,7 +584,7 @@
def removeRecordForLocalName(self, localname):
record = yield self.recordForLocalName(localname)
shareeCollection = yield self._home.sharedChildWithName(record.localname)
- yield shareeCollection._deletedSyncToken()
+ yield shareeCollection._deletedSyncToken(sharedRemoval=True)
returnValue((yield self._txn.execSQL(
"""
@@ -602,7 +602,7 @@
record = yield self.recordForShareUID(shareUID)
shareeCollection = yield self._home.sharedChildWithName(record.localname)
- yield shareeCollection._deletedSyncToken()
+ yield shareeCollection._deletedSyncToken(sharedRemoval=True)
if not shareUID.startswith("Direct"):
yield self._txn.execSQL(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101222/37a12e8a/attachment.html>
More information about the calendarserver-changes
mailing list