[CalendarServer-changes] [8685] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 15 11:09:46 PST 2012


Revision: 8685
          http://trac.macosforge.org/projects/calendarserver/changeset/8685
Author:   sagen at apple.com
Date:     2012-02-15 11:09:45 -0800 (Wed, 15 Feb 2012)
Log Message:
-----------
Delete bogus EXDATE properties, taking care to keep valid ones in a multi-value EXDATE.

Modified Paths:
--------------
    CalendarServer/trunk/support/build.sh
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/support/build.sh
===================================================================
--- CalendarServer/trunk/support/build.sh	2012-02-15 18:57:02 UTC (rev 8684)
+++ CalendarServer/trunk/support/build.sh	2012-02-15 19:09:45 UTC (rev 8685)
@@ -727,7 +727,7 @@
     "${pypi}/p/python-ldap/${ld}.tar.gz";
 
   # XXX actually PyCalendar should be imported in-place.
-  py_dependency -fe -i "src" -r 188 \
+  py_dependency -fe -i "src" -r 189 \
     "pycalendar" "pycalendar" "pycalendar" \
     "http://svn.mulberrymail.com/repos/PyCalendar/branches/server";
 

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2012-02-15 18:57:02 UTC (rev 8684)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2012-02-15 19:09:45 UTC (rev 8685)
@@ -1348,13 +1348,26 @@
                 dtstart = master.propertyValue("DTSTART")
                 if dtstart is not None:
                     for property in list(master.properties("EXDATE")):
-                        for exdate in [_exdate.getValue() for _exdate in property.value()]:
-                            if exdate < dtstart:
+                        newValues = []
+                        for exdate in property.value():
+                            exdateValue = exdate.getValue()
+                            if exdateValue < dtstart:
                                 if doFix:
-                                    master.removeProperty(property)
-                                    fixed.append("Removed earlier EXDATE: %s" % (exdate,))
+                                    fixed.append("Removed earlier EXDATE: %s" % (exdateValue,))
                                 else:
-                                    unfixed.append("EXDATE earlier than master: %s" % (exdate,))
+                                    unfixed.append("EXDATE earlier than master: %s" % (exdateValue,))
+                            else:
+                                newValues.append(exdateValue)
+
+                        if doFix:
+                            # Remove the property...
+                            master.removeProperty(property)
+                            if newValues:
+                                # ...and add it back only if it still has values
+                                property.setValue(newValues)
+                                master.addProperty(property)
+
+
             else:
                 valid_rids = set()
 

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2012-02-15 18:57:02 UTC (rev 8684)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2012-02-15 19:09:45 UTC (rev 8685)
@@ -482,7 +482,8 @@
 TRANSP:OPAQUE
 SUMMARY:RECUR
 DTSTART;TZID=US/Pacific:20120218T140000
-EXDATE;TZID=US/Pacific:20120215T113000
+EXDATE;TZID=US/Pacific:20120201T113000,20120202T113000
+EXDATE;TZID=US/Pacific:20120214T113000,20120225T113000,20120215T113000
 EXDATE;TZID=US/Pacific:20120216T113000
 EXDATE;TZID=US/Pacific:20120220T113000
 DTSTAMP:20120213T224523Z
@@ -514,15 +515,23 @@
         fixed, unfixed = calendar.validCalendarData(doFix=True,
             validateRecurrences=True)
         self.assertEquals(fixed,
-            ["Removed earlier EXDATE: 20120215T113000",
+            ["Removed earlier EXDATE: 20120201T113000",
+            "Removed earlier EXDATE: 20120202T113000",
+            "Removed earlier EXDATE: 20120214T113000",
+            "Removed earlier EXDATE: 20120215T113000",
             "Removed earlier EXDATE: 20120216T113000"]
         )
         self.assertEquals(unfixed, [])
-        # These two old EXDATES are removed
+
+        # These five old EXDATES are removed
+        self.assertTrue("EXDATE;TZID=US/Pacific:20120201T113000\r\n" not in str(calendar))
+        self.assertTrue("EXDATE;TZID=US/Pacific:20120202T113000\r\n" not in str(calendar))
+        self.assertTrue("EXDATE;TZID=US/Pacific:20120214T113000\r\n" not in str(calendar))
         self.assertTrue("EXDATE;TZID=US/Pacific:20120215T113000\r\n" not in str(calendar))
         self.assertTrue("EXDATE;TZID=US/Pacific:20120216T113000\r\n" not in str(calendar))
-        # This EXDATE remains
+        # These future EXDATEs remain (one of which used to be in a multi-value EXDATE)
         self.assertTrue("EXDATE;TZID=US/Pacific:20120220T113000\r\n" in str(calendar))
+        self.assertTrue("EXDATE;TZID=US/Pacific:20120225T113000\r\n" in str(calendar))
 
         # Now it should pass without fixing
         calendar.validCalendarData(doFix=False, validateRecurrences=True)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120215/3e454a99/attachment-0001.html>


More information about the calendarserver-changes mailing list