[CalendarServer-changes] [12191] CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common /datastore

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:18:32 PDT 2014


Revision: 12191
          http://trac.calendarserver.org//changeset/12191
Author:   cdaboo at apple.com
Date:     2013-12-23 08:55:28 -0800 (Mon, 23 Dec 2013)
Log Message:
-----------
Make sure upgrade and migration do not apply to external homes.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py
    CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/upgrade/sql/upgrades/util.py

Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py	2013-12-23 16:38:46 UTC (rev 12190)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py	2013-12-23 16:55:28 UTC (rev 12191)
@@ -216,16 +216,18 @@
 
 
     @inlineCallbacks
-    def _withEachHomeDo(self, homeTable, homeFromTxn, action, batchSize): #@UnusedVariable
+    def _withEachHomeDo(self, homeTable, homeFromTxn, action, batchSize, processExternal=False):
         """
         Implementation of L{ICalendarStore.withEachCalendarHomeDo} and
         L{IAddressbookStore.withEachAddressbookHomeDo}.
         """
         txn = yield self.newTransaction()
         try:
-            allUIDs = yield (Select([homeTable.OWNER_UID], From=homeTable)
-                             .on(txn))
+            allUIDs = yield (Select([homeTable.OWNER_UID], From=homeTable).on(txn))
             for [uid] in allUIDs:
+                home = yield homeFromTxn(txn, uid)
+                if not processExternal and home.external():
+                    continue
                 yield action(txn, (yield homeFromTxn(txn, uid)))
         except:
             a, b, c = sys.exc_info()
@@ -235,25 +237,25 @@
             yield txn.commit()
 
 
-    def withEachCalendarHomeDo(self, action, batchSize=None):
+    def withEachCalendarHomeDo(self, action, batchSize=None, processExternal=False):
         """
         Implementation of L{ICalendarStore.withEachCalendarHomeDo}.
         """
         return self._withEachHomeDo(
             schema.CALENDAR_HOME,
             lambda txn, uid: txn.calendarHomeWithUID(uid),
-            action, batchSize
+            action, batchSize, processExternal
         )
 
 
-    def withEachAddressbookHomeDo(self, action, batchSize=None):
+    def withEachAddressbookHomeDo(self, action, batchSize=None, processExternal=False):
         """
         Implementation of L{IAddressbookStore.withEachAddressbookHomeDo}.
         """
         return self._withEachHomeDo(
             schema.ADDRESSBOOK_HOME,
             lambda txn, uid: txn.addressbookHomeWithUID(uid),
-            action, batchSize
+            action, batchSize, processExternal
         )
 
 

Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/upgrade/sql/upgrades/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/upgrade/sql/upgrades/util.py	2013-12-23 16:38:46 UTC (rev 12190)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/upgrade/sql/upgrades/util.py	2013-12-23 16:55:28 UTC (rev 12191)
@@ -19,7 +19,7 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from txdav.base.propertystore.base import PropertyName
 from txdav.base.propertystore.sql import PropertyStore
-from txdav.common.datastore.sql_tables import schema
+from txdav.common.datastore.sql_tables import schema, _HOME_STATUS_EXTERNAL
 from twisted.python.failure import Failure
 
 log = Logger()
@@ -134,7 +134,7 @@
 
 
 @inlineCallbacks
-def doToEachHomeNotAtVersion(store, homeSchema, version, doIt, logStr, filterOwnerUID=None):
+def doToEachHomeNotAtVersion(store, homeSchema, version, doIt, logStr, filterOwnerUID=None, processExternal=False):
     """
     Do something to each home whose version column indicates it is older
     than the specified version. Do this in batches as there may be a lot of work to do. Also,
@@ -161,7 +161,7 @@
         txn = store.newTransaction("updateDataVersion")
         try:
             rows = yield Select(
-                [homeSchema.RESOURCE_ID, homeSchema.OWNER_UID, ],
+                [homeSchema.RESOURCE_ID, homeSchema.OWNER_UID, homeSchema.STATUS, ],
                 From=homeSchema,
                 Where=where,
                 OrderBy=homeSchema.OWNER_UID,
@@ -173,9 +173,10 @@
                 logUpgradeStatus("End {}".format(logStr), count, total)
                 returnValue(None)
 
-            # Apply to the home
-            homeResourceID, _ignore_owner_uid = rows[0]
-            yield doIt(txn, homeResourceID)
+            # Apply to the home if not external
+            homeResourceID, _ignore_owner_uid, homeStatus = rows[0]
+            if homeStatus != _HOME_STATUS_EXTERNAL or processExternal:
+                yield doIt(txn, homeResourceID)
 
             # Update the home to the current version
             yield Update(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/a0653892/attachment.html>


More information about the calendarserver-changes mailing list