[CalendarServer-changes] [5234] CalendarServer/trunk/calendarserver/tools
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 3 14:23:24 PST 2010
Revision: 5234
http://trac.macosforge.org/projects/calendarserver/changeset/5234
Author: sagen at apple.com
Date: 2010-03-03 14:23:24 -0800 (Wed, 03 Mar 2010)
Log Message:
-----------
In order to compute which events to purge, take the difference between all events, and those events who appear *after* the given cutoff date.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/purge.py
CalendarServer/trunk/calendarserver/tools/test/test_purge.py
Modified: CalendarServer/trunk/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/purge.py 2010-03-03 21:08:46 UTC (rev 5233)
+++ CalendarServer/trunk/calendarserver/tools/purge.py 2010-03-03 22:23:24 UTC (rev 5234)
@@ -49,7 +49,7 @@
filter = caldavxml.Filter(
caldavxml.ComponentFilter(
caldavxml.ComponentFilter(
- TimeRange(end=date,),
+ TimeRange(start=date,),
name=("VEVENT", "VFREEBUSY", "VAVAILABILITY"),
),
name="VCALENDAR",
@@ -67,21 +67,18 @@
for collName in calendarHome.listChildren():
collection = calendarHome.getChild(collName)
if collection.isCalendarCollection():
- # ...use their indexes to figure out which events to purge
- for name, uid, type in collection.index().indexedSearch(filter):
- resource = collection.getChild(name)
+ # ...use their indexes to figure out which events to purge.
- # indexedSearch also returns endless repeating events, but
- # we don't want to purge those
- data = resource.iCalendarText()
- try:
- calendar = iComponent.fromString(data)
- except ValueError, e:
- log.error("Error parsing %s: %s" % (name, e))
- continue
- if calendar.isRecurringUnbounded():
- continue
+ # First, get the list of all child resources...
+ resources = set(collection.listChildren())
+ # ...and ignore those that appear *after* the given cutoff
+ for name, uid, type in collection.index().indexedSearch(filter):
+ if name in resources:
+ resources.remove(name)
+
+ for name in resources:
+ resource = collection.getChild(name)
uri = "/calendars/__uids__/%s/%s/%s" % (
record.uid,
collName,
Modified: CalendarServer/trunk/calendarserver/tools/test/test_purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_purge.py 2010-03-03 21:08:46 UTC (rev 5233)
+++ CalendarServer/trunk/calendarserver/tools/test/test_purge.py 2010-03-03 22:23:24 UTC (rev 5234)
@@ -60,12 +60,15 @@
"oneshot.ics": {
"@contents" : OLD_ICS,
},
- "repeating.ics": {
- "@contents" : REPEATING_ICS,
+ "endless.ics": {
+ "@contents" : ENDLESS_ICS,
},
"awhile.ics": {
"@contents" : REPEATING_AWHILE_ICS,
},
+ "straddling.ics": {
+ "@contents" : STRADDLING_ICS,
+ },
"recent.ics": {
"@contents" : RECENT_ICS,
},
@@ -93,9 +96,12 @@
".db.sqlite": {
"@contents" : None, # ignore contents
},
- "repeating.ics": {
- "@contents" : REPEATING_ICS,
+ "endless.ics": {
+ "@contents" : ENDLESS_ICS,
},
+ "straddling.ics": {
+ "@contents" : STRADDLING_ICS,
+ },
"recent.ics": {
"@contents" : RECENT_ICS,
},
@@ -159,7 +165,7 @@
END:VCALENDAR
""".replace("\n", "\r\n")
-REPEATING_ICS = """BEGIN:VCALENDAR
+ENDLESS_ICS = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 4.0.1//EN
CALSCALE:GREGORIAN
@@ -257,6 +263,41 @@
END:VCALENDAR
""".replace("\n", "\r\n")
+STRADDLING_ICS = """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
+CREATED:20100303T213643Z
+UID:1C219DAD-D374-4822-8C98-ADBA85E253AB
+DTEND;TZID=US/Pacific:20090508T121500
+RRULE:FREQ=MONTHLY;INTERVAL=1;UNTIL=20100509T065959Z
+TRANSP:OPAQUE
+SUMMARY:Straddling cut-off
+DTSTART;TZID=US/Pacific:20090508T111500
+DTSTAMP:20100303T213704Z
+SEQUENCE:5
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
RECENT_ICS = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//iCal 4.0.1//EN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100303/0225b5e3/attachment.html>
More information about the calendarserver-changes
mailing list