[CalendarServer-changes] [8033] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 31 09:55:40 PDT 2011
Revision: 8033
http://trac.macosforge.org/projects/calendarserver/changeset/8033
Author: cdaboo at apple.com
Date: 2011-08-31 09:55:38 -0700 (Wed, 31 Aug 2011)
Log Message:
-----------
Handle arbitrary exceptions during migration by logging the error and continuing.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/test/common.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
CalendarServer/trunk/txdav/caldav/datastore/util.py
CalendarServer/trunk/txdav/carddav/datastore/util.py
Added Paths:
-----------
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/1.ics
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/2.ics
Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/1.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/1.ics (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/1.ics 2011-08-31 16:55:38 UTC (rev 8033)
@@ -0,0 +1,31 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0800
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:PDT
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0700
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:PST
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTEND;TZID=US/Pacific:20070324T124500
+UID:uid1
+DTSTAMP:20090326T145447Z
+SUMMARY:Busted
+DTSTART;TZID=US/Pacific:20070324T121500
+CREATED:20090326T145440Z
+RRULE:FREQ=DAILY
+END:VEVENT
+END:VCALENDAR
Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/2.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/2.ics (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/2.ics 2011-08-31 16:55:38 UTC (rev 8033)
@@ -0,0 +1,48 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Cyrusoft International\, Inc.//Mulberry v4.0//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:uid2
+DTSTART;TZID=US/Eastern:20060102T140000
+DURATION:PT1H
+CREATED:20060102T190000Z
+DTSTAMP:20051222T210507Z
+RRULE:FREQ=DAILY;COUNT=5
+SUMMARY:event 6-%ctr
+END:VEVENT
+BEGIN:VEVENT
+UID:uid2
+RECURRENCE-ID;TZID=US/Eastern:20060104T140000
+DTSTART;TZID=US/Eastern:20060104T160000
+DURATION:PT1H
+CREATED:20060102T190000Z
+DESCRIPTION:Some notes
+DTSTAMP:20051222T210507Z
+SUMMARY:event 6-%ctr changed again
+BEGIN:VALARM
+ACTION:AUDIO
+TRIGGER;RELATED=START:-PT10M
+X-MULBERRY-ALARM-STATUS:PENDING
+X-MULBERRY-SPEAK-TEXT:
+END:VALARM
+END:VEVENT
+END:VCALENDAR
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-08-30 18:45:44 UTC (rev 8032)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-08-31 16:55:38 UTC (rev 8033)
@@ -1854,6 +1854,7 @@
uid for uid in self.requirements
if self.requirements[uid] is not None
])
+ additionalUIDs.add("home_bad")
expectedUIDs = additionalUIDs.union(requiredUIDs)
self.assertEquals(foundUIDs, expectedUIDs)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2011-08-30 18:45:44 UTC (rev 8032)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2011-08-31 16:55:38 UTC (rev 8033)
@@ -153,6 +153,23 @@
@inlineCallbacks
+ def test_migrateBadCalendarFromFile(self):
+ """
+ C{_migrateCalendar()} can migrate a file-backed calendar to a database-
+ backed calendar.
+ """
+ fromCalendar = yield (yield self.fileTransaction().calendarHomeWithUID(
+ "home_bad")).calendarWithName("calendar_bad")
+ toHome = yield self.transactionUnderTest().calendarHomeWithUID(
+ "new-home", create=True)
+ toCalendar = yield toHome.calendarWithName("calendar")
+ ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar,
+ lambda x: x.component()))
+ self.assertEqual(ok, 1)
+ self.assertEqual(bad, 1)
+
+
+ @inlineCallbacks
def test_migrateHomeFromFile(self):
"""
L{migrateHome} will migrate an L{ICalendarHome} provider from one
Modified: CalendarServer/trunk/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/util.py 2011-08-30 18:45:44 UTC (rev 8032)
+++ CalendarServer/trunk/txdav/caldav/datastore/util.py 2011-08-31 16:55:38 UTC (rev 8033)
@@ -129,8 +129,11 @@
@param outCalendar: the L{ICalendar} to store calendar objects to.
@param getComponent: a 1-argument callable; see L{migrateHome}.
- @return: a L{Deferred} which fires when the calendar has migrated.
+ @return: a tuple of (ok count, bad count)
"""
+
+ ok_count = 0
+ bad_count = 0
outCalendar.properties().update(inCalendar.properties())
for calendarObject in (yield inCalendar.calendarObjects()):
@@ -164,15 +167,27 @@
proto =_AttachmentMigrationProto(transport)
attachment.retrieve(proto)
yield proto.done
+
+ ok_count += 1
except InternalDataStoreError:
- log.error(" Failed to migrate calendar object: %s/%s/%s" % (
+ log.error(" InternalDataStoreError: Failed to migrate calendar object: %s/%s/%s" % (
inCalendar.ownerHome().name(),
inCalendar.name(),
calendarObject.name(),
))
+ bad_count += 1
+ except Exception, e:
+ log.error(" %s: Failed to migrate calendar object: %s/%s/%s" % (
+ str(e),
+ inCalendar.ownerHome().name(),
+ inCalendar.name(),
+ calendarObject.name(),
+ ))
+ bad_count += 1
+ returnValue((ok_count, bad_count,))
class _AttachmentMigrationProto(Protocol, object):
def __init__(self, storeTransport):
Modified: CalendarServer/trunk/txdav/carddav/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/util.py 2011-08-30 18:45:44 UTC (rev 8032)
+++ CalendarServer/trunk/txdav/carddav/datastore/util.py 2011-08-31 16:55:38 UTC (rev 8033)
@@ -18,7 +18,7 @@
"""
Utility logic common to multiple backend implementations.
"""
-from twisted.internet.defer import inlineCallbacks
+from twisted.internet.defer import inlineCallbacks, returnValue
from twistedcaldav.vcard import Component as VCard
from twistedcaldav.vcard import InvalidVCardDataError
@@ -76,6 +76,9 @@
@param outAddressbook: the L{IAddressbook} to store addressbook objects to.
@param getComponent: a 1-argument callable; see L{migrateHome}.
"""
+
+ ok_count = 0
+ bad_count = 0
outAddressbook.properties().update(inAddressbook.properties())
inObjects = yield inAddressbook.addressbookObjects()
for addressbookObject in inObjects:
@@ -95,16 +98,28 @@
if outAddressbook.objectResourcesHaveProperties():
outObject.properties().update(addressbookObject.properties())
+ ok_count += 1
except InternalDataStoreError:
- log.error(" Failed to migrate adress book object: %s/%s/%s" % (
+ log.error(" InternalDataStoreError: Failed to migrate address book object: %s/%s/%s" % (
inAddressbook.ownerHome().name(),
inAddressbook.name(),
addressbookObject.name(),
))
+ bad_count += 1
+ except Exception, e:
+ log.error(" %s: Failed to migrate address book object: %s/%s/%s" % (
+ str(e),
+ inAddressbook.ownerHome().name(),
+ inAddressbook.name(),
+ addressbookObject.name(),
+ ))
+ bad_count += 1
+ returnValue((ok_count, bad_count,))
+
@inlineCallbacks
def migrateHome(inHome, outHome, getComponent=lambda x:x.component()):
yield outHome.removeAddressBookWithName("addressbook")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110831/33a779b3/attachment.html>
More information about the calendarserver-changes
mailing list