[CalendarServer-changes] [14637] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 30 14:51:52 PDT 2015
Revision: 14637
http://trac.calendarserver.org//changeset/14637
Author: sagen at apple.com
Date: 2015-03-30 14:51:52 -0700 (Mon, 30 Mar 2015)
Log Message:
-----------
If a new event matching the icaluid of a trashed event is added to a home, the trashed copy is deleted
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-03-30 19:12:10 UTC (rev 14636)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-03-30 21:51:52 UTC (rev 14637)
@@ -590,6 +590,10 @@
# objectResourcesWithUID.)
objectResources = (yield self.getCalendarResourcesForUID(uid))
for objectResource in objectResources:
+ # The matching calendar resource is in the trash, so delete it
+ if (yield objectResource.isInTrash()):
+ yield objectResource.remove(bypassTrash=True)
+ continue
if ok_object and objectResource._resourceID == ok_object._resourceID:
continue
matched_mode = ("schedule" if objectResource.isScheduleObject else "calendar")
Modified: CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_trash.py 2015-03-30 19:12:10 UTC (rev 14636)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_trash.py 2015-03-30 21:51:52 UTC (rev 14637)
@@ -1893,7 +1893,75 @@
yield txn.commit()
+ @inlineCallbacks
+ def test_trashDuplicateUID(self):
+ """
+ Verify a duplicate uid is purged from the trash when a matching event
+ is added to a collection
+ """
+ from twistedcaldav.stdconfig import config
+ self.patch(config, "EnableTrashCollection", True)
+
+ data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+DTSTART;TZID=America/Los_Angeles:20141108T093000
+DTEND;TZID=America/Los_Angeles:20141108T103000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+RRULE:FREQ=DAILY
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+RECURRENCE-ID;TZID=America/Los_Angeles:20141111T093000
+DTSTART;TZID=America/Los_Angeles:20141111T110000
+DTEND;TZID=America/Los_Angeles:20141111T120000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+"""
+
+ txn = self.store.newTransaction()
+ home = yield txn.calendarHomeWithUID("user01", create=True)
+ collection = yield home.childWithName("calendar")
+ # trash = yield home.getTrash(create=True)
+ resource = yield collection.createObjectResourceWithName(
+ "test.ics",
+ Component.allFromString(data1)
+ )
+ yield resource.toTrash()
+ yield txn.commit()
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ txn = self.store.newTransaction()
+ home = yield txn.calendarHomeWithUID("user01", create=False)
+ collection = yield home.childWithName("calendar")
+ resource = yield collection.createObjectResourceWithName(
+ "duplicate.ics",
+ Component.allFromString(data1)
+ )
+ yield txn.commit()
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # Verify the one in the trash has been deleted
+ txn = self.store.newTransaction()
+ home = yield txn.calendarHomeWithUID("user01")
+ trash = yield home.getTrash(create=True)
+ resourceNames = yield self._getResourceNames(txn, "user01", trash.name())
+ self.assertEqual(len(resourceNames), 0)
+ yield txn.commit()
+
+
@inlineCallbacks
def test_tool_emptyTrashForPrincipal(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150330/34be17a6/attachment.html>
More information about the calendarserver-changes
mailing list