[CalendarServer-changes] [6330] CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/ datastore
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 21 14:22:02 PDT 2010
Revision: 6330
http://trac.macosforge.org/projects/calendarserver/changeset/6330
Author: glyph at apple.com
Date: 2010-09-21 14:21:59 -0700 (Tue, 21 Sep 2010)
Log Message:
-----------
skip migrating existing homes
Modified Paths:
--------------
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py
CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/util.py
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py 2010-09-21 19:24:05 UTC (rev 6329)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/test/test_util.py 2010-09-21 21:21:59 UTC (rev 6330)
@@ -92,6 +92,26 @@
@inlineCallbacks
+ def test_upgradeExistingHome(self):
+ """
+ L{UpgradeToDatabaseService.startService} will skip migrating existing
+ homes.
+ """
+ startTxn = self.sqlStore.newTransaction("populate empty sample")
+ startTxn.calendarHomeWithUID("home1", create=True)
+ startTxn.commit()
+ self.topService.startService()
+ yield self.subStarted
+ vrfyTxn = self.sqlStore.newTransaction("verify sample still empty")
+ self.addCleanup(vrfyTxn.commit)
+ home = vrfyTxn.calendarHomeWithUID("home1")
+ # The default calendar is still there.
+ self.assertNotIdentical(None, home.calendarWithName("calendar"))
+ # The migrated calendar isn't.
+ self.assertIdentical(None, home.calendarWithName("calendar_1"))
+
+
+ @inlineCallbacks
def test_upgradeAttachments(self):
"""
L{UpgradeToDatabaseService.startService} upgrades calendar attachments
Modified: CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/util.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/util.py 2010-09-21 19:24:05 UTC (rev 6329)
+++ CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/util.py 2010-09-21 21:21:59 UTC (rev 6330)
@@ -91,15 +91,23 @@
for homeType, migrateFunc, eachFunc, destFunc in [
("calendar", migrateCalendarHome,
self.fileStore.eachCalendarHome,
- lambda uid, txn: txn.calendarHomeWithUID(uid, create=True)),
+ lambda txn: txn.calendarHomeWithUID),
("addressbook", migrateAddressbookHome, self.fileStore.eachAddressbookHome,
- lambda uid, txn: txn.addressbookHomeWithUID(uid, create=True))
+ lambda txn: txn.addressbookHomeWithUID)
]:
for fileTxn, fileHome in eachFunc():
uid = fileHome.uid()
self.log_warn("Migrating %s UID %r" % (homeType, uid))
sqlTxn = self.sqlStore.newTransaction()
- sqlHome = destFunc(uid, sqlTxn)
+ homeGetter = destFunc(sqlTxn)
+ if homeGetter(uid, create=False) is not None:
+ self.log_warn(
+ "%s home %r already existed not migrating" % (
+ homeType, uid))
+ sqlTxn.abort()
+ fileTxn.commit()
+ continue
+ sqlHome = homeGetter(uid, create=True)
yield migrateFunc(fileHome, sqlHome)
fileTxn.commit()
sqlTxn.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100921/c51cc492/attachment.html>
More information about the calendarserver-changes
mailing list