[CalendarServer-changes] [8593] CalendarServer/trunk/txdav/caldav

source_changes at macosforge.org source_changes at macosforge.org
Thu Jan 26 11:25:51 PST 2012


Revision: 8593
          http://trac.macosforge.org/projects/calendarserver/changeset/8593
Author:   sagen at apple.com
Date:     2012-01-26 11:25:51 -0800 (Thu, 26 Jan 2012)
Log Message:
-----------
Skip invalid calendar objects without halting migration.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
    CalendarServer/trunk/txdav/caldav/datastore/util.py
    CalendarServer/trunk/txdav/caldav/icalendarstore.py

Added Paths:
-----------
    CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/3.ics

Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/3.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/3.ics	                        (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_bad/calendar_bad/3.ics	2012-01-26 19:25:51 UTC (rev 8593)
@@ -0,0 +1,6 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+METHOD:REQUEST
+END:VCALENDAR

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2012-01-26 18:08:52 UTC (rev 8592)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2012-01-26 19:25:51 UTC (rev 8593)
@@ -170,7 +170,7 @@
         ok, bad = (yield _migrateCalendar(fromCalendar, toCalendar,
                                lambda x: x.component()))
         self.assertEqual(ok, 1)
-        self.assertEqual(bad, 1)
+        self.assertEqual(bad, 2)
 
 
     @inlineCallbacks

Modified: CalendarServer/trunk/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/util.py	2012-01-26 18:08:52 UTC (rev 8592)
+++ CalendarServer/trunk/txdav/caldav/datastore/util.py	2012-01-26 19:25:51 UTC (rev 8593)
@@ -143,7 +143,18 @@
     bad_count = 0
     outCalendar.properties().update(inCalendar.properties())
     for calendarObject in (yield inCalendar.calendarObjects()):
-        ctype = yield calendarObject.componentType()
+        try:
+            ctype = yield calendarObject.componentType()
+        except InvalidICalendarDataError, e:
+            log.error("  InvalidICalendarDataError: Failed to migrate calendar object: %s/%s/%s (%s)" % (
+                inCalendar.ownerHome().name(),
+                inCalendar.name(),
+                calendarObject.name(),
+                str(e)
+            ))
+            bad_count += 1
+            continue
+
         if ctype not in ("VEVENT", "VTODO"):
             log.error("Migration skipping unsupported (%s) calendar object %r"
                       % (ctype, calendarObject))

Modified: CalendarServer/trunk/txdav/caldav/icalendarstore.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/icalendarstore.py	2012-01-26 18:08:52 UTC (rev 8592)
+++ CalendarServer/trunk/txdav/caldav/icalendarstore.py	2012-01-26 19:25:51 UTC (rev 8593)
@@ -387,6 +387,12 @@
         Retrieve the iCalendar component type for the main component
         in this calendar object.
 
+        @raise InvalidICalendarDataError: if this L{ICalendarObject} has invalid
+            calendar data.  This should only ever happen when reading in data
+            that hasn't passed through setComponent( ) or
+            createCalendarObjectXXX( ) such as data imported from an older store
+            or an external system.
+
         @return: a string containing the component type.
         """
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120126/9cfaa60b/attachment.html>


More information about the calendarserver-changes mailing list