[CalendarServer-changes] [14978] CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav /datastore

source_changes at macosforge.org source_changes at macosforge.org
Thu Jul 16 18:25:23 PDT 2015


Revision: 14978
          http://trac.calendarserver.org//changeset/14978
Author:   cdaboo at apple.com
Date:     2015-07-16 18:25:23 -0700 (Thu, 16 Jul 2015)
Log Message:
-----------
Fix exception with missing sharer when fixing VTODOs.

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/sql.py
    CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/test/test_sql.py

Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/sql.py	2015-07-17 01:24:43 UTC (rev 14977)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/sql.py	2015-07-17 01:25:23 UTC (rev 14978)
@@ -1810,7 +1810,10 @@
 
                 # Get the originator who is the owner of the calendar resource being modified
                 originatorPrincipal = self.calendar().ownerHome().directoryRecord()
-                originatorAddresses = originatorPrincipal.calendarUserAddresses
+                if originatorPrincipal is not None:
+                    originatorAddresses = originatorPrincipal.calendarUserAddresses
+                else:
+                    originatorAddresses = ("urn:uuid:{}".format(self.calendar().ownerHome().uid),)
 
                 for component in calendar.subcomponents():
                     if component.name() != "VTODO":
@@ -1847,7 +1850,10 @@
 
                 # Get the originator who is the owner of the calendar resource being modified
                 originatorPrincipal = self.calendar().ownerHome().directoryRecord()
-                originatorAddresses = originatorPrincipal.calendarUserAddresses
+                if originatorPrincipal is not None:
+                    originatorAddresses = originatorPrincipal.calendarUserAddresses
+                else:
+                    originatorAddresses = ("urn:uuid:{}".format(self.calendar().ownerHome().uid),)
 
                 for component in calendar.subcomponents():
                     if component.name() != "VTODO":

Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/test/test_sql.py	2015-07-17 01:24:43 UTC (rev 14977)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/test/test_sql.py	2015-07-17 01:25:23 UTC (rev 14978)
@@ -1990,7 +1990,72 @@
         self.assertTrue(token is not None)
 
 
+    @inlineCallbacks
+    def test_sharedTasksMissingSharer(self):
+        """
+        Make sure that a sharee can store tasks when the sharer has been removed from
+        the directory.
+        """
+        home = yield self.homeUnderTest()
+        cal = yield home.createCalendarWithName("shared_tasks")
+        yield cal.setSupportedComponents("VTODO")
+        yield self.commit()
 
+        cal = yield self.calendarUnderTest(name="shared_tasks")
+        other = yield self.homeUnderTest(name=OTHER_HOME_UID)
+        newCalName = yield cal.shareWith(other, _BIND_MODE_WRITE)
+        self.sharedName = newCalName
+        yield self.commit()
+
+        cal = yield self.calendarUnderTest(name="shared_tasks")
+        yield cal.createCalendarObjectWithName("data1.ics", Component.fromString("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTODO
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+SUMMARY:original
+END:VTODO
+END:VCALENDAR
+"""))
+        yield self.commit()
+
+        self._sqlCalendarStore.directoryService().destroyRecord("home1")
+
+        cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name=self.sharedName, home=OTHER_HOME_UID)
+        yield cobj.setComponent(Component.fromString("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTODO
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+COMPLETED:20080601T130000Z
+SUMMARY:changed
+END:VTODO
+END:VCALENDAR
+"""))
+        yield self.commit()
+
+        cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name=self.sharedName, home=OTHER_HOME_UID)
+        comp = yield cobj.componentForUser()
+        self.assertEqual(normalize_iCalStr(comp), normalize_iCalStr("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTODO
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+COMPLETED:20080601T130000Z
+SUMMARY:changed
+END:VTODO
+END:VCALENDAR
+"""))
+        yield self.commit()
+
+
+
 class SchedulingTests(CommonCommonTests, unittest.TestCase):
     """
     CalendarObject splitting tests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150716/e0c982d4/attachment.html>


More information about the calendarserver-changes mailing list