[CalendarServer-changes] [8701] CalendarServer/branches/users/glyph/migrate-merge
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 16 04:29:05 PST 2012
Revision: 8701
http://trac.macosforge.org/projects/calendarserver/changeset/8701
Author: glyph at apple.com
Date: 2012-02-16 04:29:05 -0800 (Thu, 16 Feb 2012)
Log Message:
-----------
Make the new test pass; don't migrate items with conflicting UIDs.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/migrate-merge/
Modified: CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py 2012-02-16 12:29:02 UTC (rev 8700)
+++ CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/util.py 2012-02-16 12:29:05 UTC (rev 8701)
@@ -131,21 +131,27 @@
@inlineCallbacks
-def _migrateCalendar(inCalendar, outCalendar, getComponent):
+def _migrateCalendar(inCalendar, outCalendar, getComponent, merge):
"""
Copy all calendar objects and properties in the given input calendar to the
given output calendar.
@param inCalendar: the L{ICalendar} to retrieve calendar objects from.
+
@param outCalendar: the L{ICalendar} to store calendar objects to.
+
@param getComponent: a 1-argument callable; see L{migrateHome}.
+ @param merge: a boolean indicating whether we should attempt to merge the
+ calendars together.
+
@return: a tuple of (ok count, bad count)
"""
ok_count = 0
bad_count = 0
outCalendar.properties().update(inCalendar.properties())
+ outHome = outCalendar.ownerCalendarHome()
for calendarObject in (yield inCalendar.calendarObjects()):
try:
ctype = yield calendarObject.componentType()
@@ -163,9 +169,16 @@
log.error("Migration skipping unsupported (%s) calendar object %r"
% (ctype, calendarObject))
continue
+ if merge:
+ mightConflict = yield outHome.hasCalendarResourceUIDSomewhereElse(
+ calendarObject.uid(), None, "schedule"
+ )
+ if mightConflict:
+ continue
try:
# Must account for metadata
- component = (yield calendarObject.component()) # XXX WRONG SHOULD CALL getComponent
+ component = (yield calendarObject.component())
+ # ^ FIXME: TESTME: SHOULD CALL 'getComponent' argument
component.md5 = calendarObject.md5()
yield outCalendar.createCalendarObjectWithName(
calendarObject.name(),
@@ -322,7 +335,8 @@
yield d
outCalendar = yield outHome.calendarWithName(name)
try:
- yield _migrateCalendar(calendar, outCalendar, getComponent)
+ yield _migrateCalendar(calendar, outCalendar, getComponent,
+ merge=merge)
except InternalDataStoreError:
log.error(
" Failed to migrate calendar: %s/%s" % (inHome.name(), name,)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120216/9ef6c622/attachment-0001.html>
More information about the calendarserver-changes
mailing list