[CalendarServer-changes] [6298] CalendarServer/trunk/txdav

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 15 14:08:39 PDT 2010


Revision: 6298
          http://trac.macosforge.org/projects/calendarserver/changeset/6298
Author:   cdaboo at apple.com
Date:     2010-09-15 14:08:36 -0700 (Wed, 15 Sep 2010)
Log Message:
-----------
Catch errors during migration and log them and ignore.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/util.py
    CalendarServer/trunk/txdav/carddav/datastore/util.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/util.py	2010-09-15 20:04:31 UTC (rev 6297)
+++ CalendarServer/trunk/txdav/caldav/datastore/util.py	2010-09-15 21:08:36 UTC (rev 6298)
@@ -25,8 +25,10 @@
 from twext.python.vcomponent import VComponent
 
 from txdav.common.icommondatastore import InvalidObjectResourceError, \
-    NoSuchObjectResourceError
+    NoSuchObjectResourceError, InternalDataStoreError
 
+from twext.python.log import Logger
+log = Logger()
 
 def validateCalendarComponent(calendarObject, calendar, component, inserting):
     """
@@ -118,27 +120,36 @@
     """
     outCalendar.properties().update(inCalendar.properties())
     for calendarObject in inCalendar.calendarObjects():
-        outCalendar.createCalendarObjectWithName(
-            calendarObject.name(),
-            calendarObject.component()) # XXX WRONG SHOULD CALL getComponent
+        
+        try:
+            outCalendar.createCalendarObjectWithName(
+                calendarObject.name(),
+                calendarObject.component()) # XXX WRONG SHOULD CALL getComponent
+    
+            # Only the owner's properties are migrated, since previous releases of
+            # calendar server didn't have per-user properties.
+            outObject = outCalendar.calendarObjectWithName(
+                calendarObject.name())
+            outObject.properties().update(calendarObject.properties())
+    
+            # Migrate attachments.
+            for attachment in calendarObject.attachments():
+                name = attachment.name()
+                ctype = attachment.contentType()
+                transport = outObject.createAttachmentWithName(name, ctype)
+                proto =_AttachmentMigrationProto(transport)
+                attachment.retrieve(proto)
+                yield proto.done
 
-        # Only the owner's properties are migrated, since previous releases of
-        # calendar server didn't have per-user properties.
-        outObject = outCalendar.calendarObjectWithName(
-            calendarObject.name())
-        outObject.properties().update(calendarObject.properties())
+        except InternalDataStoreError:
+            log.error("  Failed to migrate calendar object: %s/%s/%s" % (
+                inCalendar.ownerHome().name(),
+                inCalendar.name(),
+                calendarObject.name(),
+            ))
 
-        # Migrate attachments.
-        for attachment in calendarObject.attachments():
-            name = attachment.name()
-            ctype = attachment.contentType()
-            transport = outObject.createAttachmentWithName(name, ctype)
-            proto =_AttachmentMigrationProto(transport)
-            attachment.retrieve(proto)
-            yield proto.done
 
 
-
 class _AttachmentMigrationProto(Protocol, object):
     def __init__(self, storeTransport):
         self.storeTransport = storeTransport
@@ -180,7 +191,11 @@
         name = calendar.name()
         outHome.createCalendarWithName(name)
         outCalendar = outHome.calendarWithName(name)
-        yield _migrateCalendar(calendar, outCalendar, getComponent)
+        try:
+            yield _migrateCalendar(calendar, outCalendar, getComponent)
+        except InternalDataStoreError:
+            log.error("  Failed to migrate calendar: %s/%s" % (inHome.name(), name,))
+
     # No migration for notifications, since they weren't present in earlier
     # released versions of CalendarServer.
 

Modified: CalendarServer/trunk/txdav/carddav/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/util.py	2010-09-15 20:04:31 UTC (rev 6297)
+++ CalendarServer/trunk/txdav/carddav/datastore/util.py	2010-09-15 21:08:36 UTC (rev 6298)
@@ -23,8 +23,11 @@
 from twistedcaldav.vcard import InvalidVCardDataError
 
 from txdav.common.icommondatastore import InvalidObjectResourceError, \
-    NoSuchObjectResourceError
+    NoSuchObjectResourceError, InternalDataStoreError
 
+from twext.python.log import Logger
+log = Logger()
+
 def validateAddressBookComponent(addressbookObject, vcard, component, inserting):
     """
     Validate an addressbook component for a particular addressbook.
@@ -70,15 +73,24 @@
     """
     outAddressbook.properties().update(inAddressbook.properties())
     for addressbookObject in inAddressbook.addressbookObjects():
-        outAddressbook.createAddressBookObjectWithName(
-            addressbookObject.name(),
-            addressbookObject.component()) # XXX WRONG SHOULD CALL getComponent
+        
+        try:
+            outAddressbook.createAddressBookObjectWithName(
+                addressbookObject.name(),
+                addressbookObject.component()) # XXX WRONG SHOULD CALL getComponent
+    
+            # Only the owner's properties are migrated, since previous releases of
+            # addressbook server didn't have per-user properties.
+            outAddressbook.addressbookObjectWithName(
+                addressbookObject.name()).properties().update(
+                    addressbookObject.properties())
 
-        # Only the owner's properties are migrated, since previous releases of
-        # addressbook server didn't have per-user properties.
-        outAddressbook.addressbookObjectWithName(
-            addressbookObject.name()).properties().update(
-                addressbookObject.properties())
+        except InternalDataStoreError:
+            log.error("  Failed to migrate adress book object: %s/%s/%s" % (
+                inAddressbook.ownerHome().name(),
+                inAddressbook.name(),
+                addressbookObject.name(),
+            ))
 
 
 def migrateHome(inHome, outHome, getComponent=lambda x:x.component()):
@@ -88,6 +100,9 @@
         name = addressbook.name()
         outHome.createAddressBookWithName(name)
         outAddressbook = outHome.addressbookWithName(name)
-        _migrateAddressbook(addressbook, outAddressbook, getComponent)
+        try:
+            _migrateAddressbook(addressbook, outAddressbook, getComponent)
+        except InternalDataStoreError:
+            log.error("  Failed to migrate address book: %s/%s" % (inHome.name(), name,))
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100915/3fc7fde1/attachment.html>


More information about the calendarserver-changes mailing list