[CalendarServer-changes] [6359] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 23 15:48:32 PDT 2010
Revision: 6359
http://trac.macosforge.org/projects/calendarserver/changeset/6359
Author: glyph at apple.com
Date: 2010-09-23 15:48:31 -0700 (Thu, 23 Sep 2010)
Log Message:
-----------
bring forward migration fix from more-deferreds branch
Modified Paths:
--------------
CalendarServer/trunk/txdav/common/datastore/test/test_util.py
CalendarServer/trunk/txdav/common/datastore/util.py
Property Changed:
----------------
CalendarServer/trunk/
Property changes on: CalendarServer/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/wsanchez/transations:5515-5593
+ /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/more-deferreds-6:6330
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/wsanchez/transations:5515-5593
Modified: CalendarServer/trunk/txdav/common/datastore/test/test_util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_util.py 2010-09-23 21:28:48 UTC (rev 6358)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_util.py 2010-09-23 22:48:31 UTC (rev 6359)
@@ -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/trunk/txdav/common/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/util.py 2010-09-23 21:28:48 UTC (rev 6358)
+++ CalendarServer/trunk/txdav/common/datastore/util.py 2010-09-23 22:48:31 UTC (rev 6359)
@@ -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(migrating=True)
- 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/20100923/83c67ebd/attachment.html>
More information about the calendarserver-changes
mailing list