[CalendarServer-changes] [15185] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 13 10:55:36 PDT 2015


Revision: 15185
          http://trac.calendarserver.org//changeset/15185
Author:   cdaboo at apple.com
Date:     2015-10-13 10:55:36 -0700 (Tue, 13 Oct 2015)
Log Message:
-----------
Fix for missing attachment error when attendee shares their invite back to the organizer.

Modified Paths:
--------------
    CalendarServer/trunk/requirements-dev.txt
    CalendarServer/trunk/txdav/caldav/datastore/sql.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py

Modified: CalendarServer/trunk/requirements-dev.txt
===================================================================
--- CalendarServer/trunk/requirements-dev.txt	2015-10-13 17:54:20 UTC (rev 15184)
+++ CalendarServer/trunk/requirements-dev.txt	2015-10-13 17:55:36 UTC (rev 15185)
@@ -8,4 +8,4 @@
 q
 tl.eggdeps
 --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@14856#egg=CalDAVClientLibrary
---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@15159#egg=CalDAVTester
+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@15184#egg=CalDAVTester

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py	2015-10-13 17:54:20 UTC (rev 15184)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py	2015-10-13 17:55:36 UTC (rev 15185)
@@ -28,7 +28,7 @@
 
 from twext.enterprise.dal.record import fromTable, SerializableRecord
 from twext.enterprise.dal.syntax import Count, ColumnSyntax, Delete, \
-    Insert, Len, Max, Parameter, Select, Update, utcNowSQL
+    Insert, Len, Max, Parameter, Select, Update, utcNowSQL, Union
 from twext.enterprise.locking import NamedLock
 from twext.enterprise.jobs.jobitem import JobItem
 from twext.enterprise.jobs.workitem import WorkItem, AggregatedWorkItem, \
@@ -659,7 +659,9 @@
             From=co.join(cb, co.PARENT_RESOURCE_ID == cb.RESOURCE_ID,
                          'left outer'),
             Where=(co.DROPBOX_ID == dropboxID).And(
-                cb.HOME_RESOURCE_ID == self._resourceID)
+                cb.HOME_RESOURCE_ID == self._resourceID).And(
+                cb.BIND_MODE == _BIND_MODE_OWN).And(
+                cb.CALENDAR_RESOURCE_NAME != "inbox"),
         ).on(self._txn))
 
         if rows:
@@ -697,17 +699,37 @@
 
     @inlineCallbacks
     def getAllDropboxIDs(self):
-        co = self._objectSchema
-        cb = self._bindSchema
+        """
+        Only return dropbox-IDs that actually have an attachment associated with them. To do that we will
+        look at the ATTACHMENT table and get all (old) dropbox ids for the home. Then look at the combined
+        ATTACHMENT and ATTACHMENT_CALENDAR_OBJECT table to get all managed attachment drop box ids. Those
+        results need to be unique and sorted.
+        """
+        att = schema.ATTACHMENT
+        attco = schema.ATTACHMENT_CALENDAR_OBJECT
+        co = schema.CALENDAR_OBJECT
+
+        # Old dropbox items (DROPBOX_ID != "." in ATTACHMENT table)
         rows = (yield Select(
-            [co.DROPBOX_ID],
-            From=co.join(cb, co.PARENT_RESOURCE_ID == cb.RESOURCE_ID),
-            Where=(co.DROPBOX_ID != None).And(
-                co.TRASHED == None).And(
-                cb.HOME_RESOURCE_ID == self._resourceID),
-            OrderBy=co.DROPBOX_ID
+            [att.DROPBOX_ID],
+            From=att.join(co, att.DROPBOX_ID == co.DROPBOX_ID),
+            Where=(att.CALENDAR_HOME_RESOURCE_ID == self._resourceID).And(
+                att.DROPBOX_ID != ".").And(
+                co.TRASHED == None),
+            SetExpression=Union(
+                Select(
+                    [co.DROPBOX_ID],
+                    From=att.join(
+                        attco, att.ATTACHMENT_ID == attco.ATTACHMENT_ID).join(
+                        co, attco.CALENDAR_OBJECT_RESOURCE_ID == co.RESOURCE_ID),
+                    Where=(att.CALENDAR_HOME_RESOURCE_ID == self._resourceID).And(
+                        att.DROPBOX_ID == ".").And(
+                        co.TRASHED == None),
+                ),
+                optype=Union.OPTYPE_ALL,
+            )
         ).on(self._txn))
-        returnValue([row[0] for row in rows])
+        returnValue(sorted(set([row[0] for row in rows])))
 
 
     @inlineCallbacks

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2015-10-13 17:54:20 UTC (rev 15184)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2015-10-13 17:55:36 UTC (rev 15185)
@@ -304,6 +304,7 @@
         L{ICalendarObject.getAllDropboxIDs} returns a L{Deferred} that fires
         with a C{list} of all Dropbox IDs.
         """
+        yield self.createAttachmentTest(lambda x: x)
         home = yield self.homeUnderTest()
         # The only item in the home which has an ATTACH or X-APPLE-DROPBOX
         # property.
@@ -988,6 +989,23 @@
         self.assertEquals(data2, "test data 2")
 
 
+    @inlineCallbacks
+    def test_dropboxIDs(self):
+        """
+        L{ICalendarObject.getAllDropboxIDs} returns a L{Deferred} that fires
+        with a C{list} of all Dropbox IDs.
+        """
+        yield self.createAttachmentTest(lambda x: x)
+        home = yield self.homeUnderTest()
+        # The only item in the home which has an ATTACH or X-APPLE-DROPBOX
+        # property.
+        allDropboxIDs = set([
+            u'FE5CDC6F-7776-4607-83A9-B90FF7ACC8D0.dropbox',
+        ])
+        self.assertEquals(set((yield home.getAllDropboxIDs())),
+                          allDropboxIDs)
+
+
     def test_createAttachment(self):
         """
         L{ICalendarObject.createManagedAttachment} will store an
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151013/17cc75de/attachment.html>


More information about the calendarserver-changes mailing list