[CalendarServer-changes] [14672] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 10 10:57:10 PDT 2015


Revision: 14672
          http://trac.calendarserver.org//changeset/14672
Author:   sagen at apple.com
Date:     2015-04-10 10:57:10 -0700 (Fri, 10 Apr 2015)
Log Message:
-----------
Simplification of ObjectResource removal APIs:  .remove( ) always does implicit and will move to trash if enabled; .purge(implicitly=True) always bypasses the trash, and implicit can be turned off

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/calverify.py
    CalendarServer/trunk/calendarserver/tools/purge.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py
    CalendarServer/trunk/txdav/caldav/datastore/sql.py
    CalendarServer/trunk/txdav/caldav/datastore/sql_external.py
    CalendarServer/trunk/txdav/caldav/datastore/test/common.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
    CalendarServer/trunk/txdav/carddav/datastore/sql.py
    CalendarServer/trunk/txdav/common/datastore/file.py
    CalendarServer/trunk/txdav/common/datastore/podding/migration/home_sync.py
    CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py
    CalendarServer/trunk/txdav/common/datastore/sql.py
    CalendarServer/trunk/txdav/common/datastore/sql_external.py
    CalendarServer/trunk/txdav/common/datastore/sql_notification.py
    CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
    CalendarServer/trunk/txdav/common/datastore/test/util.py
    CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py

Modified: CalendarServer/trunk/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/calverify.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/calendarserver/tools/calverify.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -739,7 +739,7 @@
             calendar = yield home.childWithID(calendarID)
             calendarObj = yield calendar.objectResourceWithID(resid)
             objname = calendarObj.name()
-            yield calendarObj.remove(implicitly=False, bypassTrash=True)
+            yield calendarObj.purge(implicitly=False)
             yield self.txn.commit()
             self.txn = self.store.newTransaction()
 

Modified: CalendarServer/trunk/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/purge.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/calendarserver/tools/purge.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -994,7 +994,7 @@
             yield storeCalHome.removeUnacceptedShares()
             notificationHome = yield txn.notificationsWithUID(storeCalHome.uid())
             if notificationHome is not None:
-                yield notificationHome.remove(bypassTrash=True)
+                yield notificationHome.purge()
 
 
     @inlineCallbacks
@@ -1059,7 +1059,7 @@
                     if not self.dryrun:
                         retry = False
                         try:
-                            yield childResource.remove(implicitly=doScheduling, bypassTrash=True)
+                            yield childResource.purge(implicitly=doScheduling)
                             incrementCount = True
                         except Exception, e:
                             print("Exception deleting %s: %s" % (uri, str(e)))
@@ -1069,7 +1069,7 @@
                             # Try again with implicit scheduling off
                             print("Retrying deletion of %s with scheduling turned off" % (uri,))
                             try:
-                                yield childResource.remove(implicitly=False, bypassTrash=True)
+                                yield childResource.purge(implicitly=False)
                                 incrementCount = True
                             except Exception, e:
                                 print("Still couldn't delete %s even with scheduling turned off: %s" % (uri, str(e)))
@@ -1112,7 +1112,7 @@
                                 print("Deleting calendar: %s" % (calendarName,))
                         if not self.dryrun:
                             if calColl.owned():
-                                yield storeCalHome.removeChildWithName(calendarName, bypassTrash=True)
+                                yield storeCalHome.removeChildWithName(calendarName, useTrash=False)
                             else:
                                 yield calColl.unshare()
 
@@ -1179,7 +1179,7 @@
                     if not self.dryrun:
                         # Also remove the addressbook collection itself
                         if abColl.owned():
-                            yield storeAbHome.removeChildWithName(abName, bypassTrash=True)
+                            yield storeAbHome.removeChildWithName(abName, useTrash=False)
                         else:
                             yield abColl.unshare()
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -1009,7 +1009,7 @@
         @type name: C{str}
         """
 
-        yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
+        yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL, useTrash=False)
 
 
     def resetAttendeePartstat(self, component, cuas, partstat, hadRSVP=False):

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -43,7 +43,7 @@
             # Delete all but the first one
             log.debug("Should only have zero or one scheduling object resource with UID '%s' in calendar home: %s" % (uid, calendar_home,))
             for resource in objectResources[1:]:
-                yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
+                yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL, useTrash=False)
             objectResources = objectResources[:1]
 
         returnValue(objectResources[0] if len(objectResources) == 1 else None)

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -591,7 +591,7 @@
         for objectResource in objectResources:
             # The matching calendar resource is in the trash, so delete it
             if (yield objectResource.isInTrash()):
-                yield objectResource.remove(bypassTrash=True)
+                yield objectResource.purge(implicitly=False)
                 continue
             if ok_object and objectResource._resourceID == ok_object._resourceID:
                 continue
@@ -1321,7 +1321,7 @@
 
         if child is None:
             child = yield self.objectResourceWithID(rid)
-        yield child._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
+        yield child._removeInternal(internal_state=ComponentRemoveState.INTERNAL, useTrash=False)
 
 
     def calendarObjectsInTimeRange(self, start, end, timeZone):
@@ -3598,7 +3598,7 @@
 
                     # Now forcibly delete the event
                     if not inserting:
-                        yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
+                        yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL, useTrash=False)
                         raise ResourceDeletedError("Resource modified but immediately deleted by the server.")
                     else:
                         raise AttendeeAllowedError("Attendee cannot create event for Organizer: {0}".format(implicit_result,))
@@ -4173,28 +4173,32 @@
 
 
     @inlineCallbacks
-    def remove(self, implicitly=True, bypassTrash=False):
-        if (yield self.isInTrash()):
-            implicitly = False
-        returnValue((
-            yield self._removeInternal(
-                internal_state=ComponentRemoveState.NORMAL if implicitly else ComponentRemoveState.NORMAL_NO_IMPLICIT, bypassTrash=bypassTrash
-            )
-        ))
+    def toTrash(self):
+        yield self._removeInternal(
+            internal_state=ComponentRemoveState.NORMAL, useTrash=config.EnableTrashCollection
+        )
 
 
-    def purge(self):
+    @inlineCallbacks
+    def _reallyRemove(self):
+        yield self._removeInternal(
+            internal_state=ComponentRemoveState.NORMAL, useTrash=False
+        )
+
+
+    @inlineCallbacks
+    def purge(self, implicitly=True):
         """
-        Do a "silent" removal of this object resource.
+        Do an (optionally implicit) removal of this object resource, bypassing the trash.
         """
-        return self._removeInternal(
-            ComponentRemoveState.NORMAL_NO_IMPLICIT, bypassTrash=True
+        yield self._removeInternal(
+            internal_state=ComponentRemoveState.NORMAL if implicitly else ComponentRemoveState.NORMAL_NO_IMPLICIT, useTrash=False
         )
 
 
     @inlineCallbacks
     def _removeInternal(
-        self, internal_state=ComponentRemoveState.NORMAL, bypassTrash=False
+        self, internal_state=ComponentRemoveState.NORMAL, useTrash=False
     ):
 
         isinbox = self._calendar.isInbox()
@@ -4205,6 +4209,13 @@
             # Get data we need for implicit scheduling
             calendar = (yield self.componentForUser())
             scheduler = ImplicitScheduler(logItems=self._txn.logItems)
+            # Cannot do implicit in sharee's shared calendar
+            if not self.calendar().owned():
+                scheduler.setSchedulingNotAllowed(
+                    ShareeAllowedError,
+                    "Sharee's cannot schedule",
+                )
+
             do_implicit_action, _ignore = (yield scheduler.testImplicitSchedulingDELETE(
                 self.calendar(),
                 self,
@@ -4214,40 +4225,31 @@
             if do_implicit_action:
                 yield NamedLock.acquire(self._txn, "ImplicitUIDLock:{0}".format(hashlib.md5(calendar.resourceUID()).hexdigest(),))
 
-
         if isinbox:
-            bypassTrash = True
+            useTrash = False
         else:
             calendar = (yield self.componentForUser())
             status = calendar.mainComponent().getProperty("STATUS")
             if status is not None:
                 status = status.strvalue()
                 if status == "CANCELLED":
-                    bypassTrash = True
+                    useTrash = False
 
-        if bypassTrash:
+        if useTrash:
+            # Always remove the group attendee link to prevent trashed items from being reconciled when a group changes
+            yield GroupAttendeeRecord.deletesimple(self._txn, resourceID=self._resourceID)
+
+            yield super(CalendarObject, self).toTrash()
+
+        else:
             # Need to also remove attachments
             if internal_state != ComponentRemoveState.INTERNAL:
                 if self._dropboxID:
                     yield DropBoxAttachment.resourceRemoved(self._txn, self._resourceID, self._dropboxID)
                 yield ManagedAttachment.resourceRemoved(self._txn, self._resourceID)
 
-            yield super(CalendarObject, self).reallyRemove()
-        else:
-            # Always remove the group attendee link to prevent trashed items from being reconciled when a group changes
-            yield GroupAttendeeRecord.deletesimple(self._txn, resourceID=self._resourceID)
+            yield super(CalendarObject, self)._reallyRemove()
 
-            # Do scheduling check before the move to trash
-            if scheduler is not None:
-                # Cannot do implicit in sharee's shared calendar
-                if not self.calendar().owned():
-                    scheduler.setSchedulingNotAllowed(
-                        ShareeAllowedError,
-                        "Sharee's cannot schedule",
-                    )
-
-            yield super(CalendarObject, self).remove()
-
         # Do scheduling
         if scheduler is not None:
             yield scheduler.doImplicitScheduling()
@@ -5122,7 +5124,7 @@
             yield self._setComponentInternal(ical_new, internal_state=ComponentUpdateState.SPLIT_ATTENDEE)
         else:
             # The split removed all components from this object - remove it
-            yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
+            yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL, useTrash=False)
 
         # Create a new resource and store its data (but not if the parent is "inbox", or if it is empty)
         if not self.calendar().isInbox() and ical_old.mainType() is not None:

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql_external.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql_external.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql_external.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -219,7 +219,7 @@
 
 
     def _removeInternal(
-        self, internal_state=ComponentRemoveState.NORMAL, bypassTrash=False
+        self, internal_state=ComponentRemoveState.NORMAL, useTrash=False
     ):
         raise AssertionError("CalendarObjectExternal: not supported")
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -883,7 +883,7 @@
         ctxn = self.concurrentTransaction()
         calendar1prime = yield self.calendarUnderTest(ctxn)
         obj1 = yield calendar1prime.calendarObjectWithName("1.ics")
-        yield obj1.remove(bypassTrash=True)
+        yield obj1.purge()
         yield ctxn.commit()
         try:
             retrieval = yield calendarObject.component()

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -687,7 +687,7 @@
 
         # Fully remove resource
         objects = yield self.trashObjectsUnderTest()
-        yield objects[0].remove(bypassTrash=True)
+        yield objects[0].purge()
         yield self.commit()
 
         # Attachments don't exist and will not count towards quota
@@ -741,7 +741,7 @@
 
         # Remove resource
         obj = yield self.calendarObjectUnderTest()
-        yield obj.remove(bypassTrash=True)
+        yield obj.purge()
         yield self.commit()
 
         self.assertFalse(os.path.exists(apath1))
@@ -836,7 +836,7 @@
 
         # Remove resource
         obj = yield self.calendarObjectUnderTest()
-        yield obj.remove(bypassTrash=True)
+        yield obj.purge()
         yield self.commit()
 
         self.assertTrue(os.path.exists(apath))
@@ -848,7 +848,7 @@
 
         # Remove resource
         obj = yield self.calendarObjectUnderTest(name="test.ics")
-        yield obj.remove(bypassTrash=True)
+        yield obj.purge()
         yield self.commit()
 
         self.assertFalse(os.path.exists(apath))
@@ -1314,7 +1314,7 @@
 
         # Fully remove resource
         objects = yield self.trashObjectsUnderTest()
-        yield objects[0].remove(bypassTrash=True)
+        yield objects[0].purge()
         yield self.commit()
 
         # Attachments don't exist and will not count towards quota
@@ -1362,7 +1362,7 @@
 
         # Remove resource
         obj = yield self.calendarObjectUnderTest()
-        yield obj.remove(bypassTrash=True)
+        yield obj.purge()
         yield self.commit()
 
         self.assertFalse(os.path.exists(apath1))
@@ -1402,7 +1402,7 @@
 
         # Remove resource
         obj = yield self.calendarObjectUnderTest()
-        yield obj.remove(bypassTrash=True)
+        yield obj.purge()
         yield self.commit()
 
         self.assertTrue(os.path.exists(apath))
@@ -1414,7 +1414,7 @@
 
         # Remove resource
         obj = yield self.calendarObjectUnderTest(name="test.ics")
-        yield obj.remove(bypassTrash=True)
+        yield obj.purge()
         yield self.commit()
 
         self.assertFalse(os.path.exists(apath))

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -827,7 +827,7 @@
 
         # Remove calendar and check for no properties
         home = yield self.homeUnderTest()
-        yield home.removeCalendarWithName(name, bypassTrash=True)
+        yield home.removeCalendarWithName(name, useTrash=False)
         rows = yield _allWithID.on(self.transactionUnderTest(), resourceID=resourceID)
         self.assertEqual(len(tuple(rows)), 0)
         yield self.commit()
@@ -1218,7 +1218,7 @@
         home = yield self.transactionUnderTest().calendarHomeWithUID("home_defaults")
         self.assertEqual(home._default_events, default_events._resourceID)
         self.assertEqual(home._default_tasks, default_tasks._resourceID)
-        yield home.removeCalendarWithName("calendar_1-vtodo", bypassTrash=False)
+        yield home.removeCalendarWithName("calendar_1-vtodo", useTrash=True)
         yield self.commit()
 
         home = yield self.transactionUnderTest().calendarHomeWithUID("home_defaults")
@@ -1297,7 +1297,7 @@
 
         home = yield self.homeUnderTest(name="home_defaults")
         calendar1 = yield home.calendarWithName("calendar_1")
-        yield calendar1.remove(bypassTrash=False)
+        yield calendar1.remove()
         yield self.commit()
 
         home = yield self.homeUnderTest(name="home_defaults")
@@ -1335,7 +1335,7 @@
 
             home = yield self.homeUnderTest(name="home_defaults")
             calendar1 = yield home.calendarWithName("calendar_1")
-            yield calendar1.remove(bypassTrash=False)
+            yield calendar1.remove()
             default_events = yield home.defaultCalendar("VEVENT", create=False)
             self.assertTrue(default_events is None)
             yield self.commit()
@@ -3599,7 +3599,7 @@
     @inlineCallbacks
     def test_calendarObjectSplit_removed(self):
         """
-        Test that splitting of calendar objects dioes not occur when the object is
+        Test that splitting of calendar objects does not occur when the object is
         removed before the work can be done.
         """
         self.patch(config.Scheduling.Options.Splitting, "Enabled", True)
@@ -3677,7 +3677,7 @@
         yield self.abort()
 
         cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="user01")
-        yield cobj.remove(bypassTrash=True)
+        yield cobj.purge(implicitly=True)
         yield self.commit()
 
         rows = yield Select(

Modified: CalendarServer/trunk/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/sql.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/carddav/datastore/sql.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -888,7 +888,7 @@
 
 
     @inlineCallbacks
-    def remove(self, bypassTrash=True):
+    def remove(self):
 
         if self._resourceID == self._home._resourceID:
 
@@ -908,6 +908,7 @@
         else:
             returnValue((yield super(AddressBook, self).remove()))
 
+    purge = remove
 
     def rename(self, name):
         # better error?
@@ -2152,7 +2153,7 @@
                     removed=True,
                 )
 
-        yield super(AddressBookObject, self).reallyRemove() # FIXME: carddav trash?
+        yield super(AddressBookObject, self)._reallyRemove() # FIXME: carddav trash?
         self._kind = None
         self._ownerAddressBookResourceID = None
         self._objectText = None

Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/file.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -848,7 +848,7 @@
 
 
     @writeOperation
-    def removeChildWithName(self, name, bypassTrash=False):
+    def removeChildWithName(self, name, useTrash=True):
         if name.startswith(".") or name in self._removedChildren:
             raise NoSuchHomeChildError(name)
 
@@ -1403,7 +1403,7 @@
         raise NotImplementedError
 
 
-    def remove(self, bypassTrash=False):
+    def remove(self):
 
         # FIXME: test for undo
         objectResourcePath = self._path
@@ -1414,6 +1414,7 @@
 
         self._parentCollection.removedObjectResource(self)
 
+    purge = remove
 
     def _text(self):
         raise NotImplementedError

Modified: CalendarServer/trunk/txdav/common/datastore/podding/migration/home_sync.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/podding/migration/home_sync.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/podding/migration/home_sync.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -647,7 +647,7 @@
         local_objects = yield local_calendar.objectResourcesWithNames(purge_names)
 
         for local_object in local_objects:
-            yield local_object.purge()
+            yield local_object.purge(implicitly=False)
             self.accounting("  Purged calendar object local-id={}.".format(local_object.id()))
 
 
@@ -737,7 +737,7 @@
 
         # Purge the ones that remain
         for local_object in local_objects.values():
-            yield local_object.purge()
+            yield local_object.purge(implicitly=False)
             self.accounting("  Purged calendar object local-id={}.".format(local_object.id()))
 
 

Modified: CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -552,7 +552,7 @@
         home0 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name="user01", create=True)
         calendar0 = yield home0.childWithName("new-calendar")
         del details0[calendar0.id()]
-        yield calendar0.remove(bypassTrash=True)
+        yield calendar0.purge()
         yield self.commitTransaction(0)
 
         # Trigger sync

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -1089,7 +1089,7 @@
             home = (yield self.calendarHomeWithUID(uid))
             calendar = (yield home.childWithName(calendarName))
             resource = (yield calendar.objectResourceWithName(eventName))
-            yield resource.remove(implicitly=False, bypassTrash=True)
+            yield resource.purge(implicitly=False)
             count += 1
         returnValue(count)
 
@@ -2312,14 +2312,18 @@
 
 
     @inlineCallbacks
-    def removeChildWithName(self, name, bypassTrash=False):
+    def removeChildWithName(self, name, useTrash=True):
         child = yield self.childWithName(name)
         if child is None:
             raise NoSuchHomeChildError()
         key = self._childrenKey(child.isInTrash())
         resourceID = child._resourceID
 
-        yield child.remove(bypassTrash=bypassTrash)
+        if useTrash:
+            yield child.remove()
+        else:
+            yield child.purge()
+
         self._children[key].pop(name, None)
         self._children[key].pop(resourceID, None)
 
@@ -2961,7 +2965,7 @@
                     msg = "   Removing \"{}\"...".format(summary)
                     print(msg)
                     log.info(msg)
-                yield child.reallyRemove()
+                yield child.purge(implicitly=False)
             if verbose:
                 print("")
 
@@ -2982,7 +2986,7 @@
                     msg = "   Removing \"{}\"...".format(summary)
                     print(msg)
                     log.info(msg)
-                yield child.reallyRemove()
+                yield child.purge(implicitly=False)
             if verbose:
                 print("")
 
@@ -2991,7 +2995,7 @@
                     msg = "Removing collection \"{}\"...".format(displayName.encode("utf-8"))
                     print(msg)
                     log.info(msg)
-                yield collection.reallyRemove()
+                yield collection.purge()
 
 
     @inlineCallbacks
@@ -3577,9 +3581,10 @@
 
 
     @inlineCallbacks
-    def remove(self, bypassTrash=False):
+    def remove(self):
         """
-        Just moves the collection to the trash
+        If trash is enabled, move the collection to trash, otherwise fully
+        delete it.
         """
 
         if config.EnableTrashCollection:
@@ -3587,16 +3592,13 @@
             if isInTrash:
                 raise AlreadyInTrashError
             else:
-                if bypassTrash:
-                    yield self.reallyRemove()
-                else:
-                    yield self.toTrash()
+                yield self.toTrash()
         else:
-            yield self.reallyRemove()
+            yield self._reallyRemove()
 
 
     @inlineCallbacks
-    def reallyRemove(self):
+    def _reallyRemove(self):
 
         # Stop sharing first
         yield self.ownerDeleteShare()
@@ -3728,9 +3730,9 @@
 
     def purge(self):
         """
-        Do a "silent" removal of this object resource.
+        Do a "silent" removal of this child.
         """
-        return self.reallyRemove()
+        return self._reallyRemove()
 
 
     def ownerHome(self):
@@ -5062,9 +5064,9 @@
         raise NotImplementedError
 
 
-    def remove(self, options=None):
+    def remove(self):
         """
-        Just moves the object to the trash
+        If trash is enabled move the object to the trash, otherwise fully delete it
         """
 
         if config.EnableTrashCollection:
@@ -5073,11 +5075,11 @@
             else:
                 return self.toTrash()
         else:
-            return self.reallyRemove(options=options)
+            return self._reallyRemove()
 
 
     @inlineCallbacks
-    def reallyRemove(self, options=None):
+    def _reallyRemove(self):
         """
         Remove, bypassing the trash
         """
@@ -5185,9 +5187,9 @@
 
     def purge(self):
         """
-        Do a "silent" removal of this object resource.
+        Delete this object, bypassing trash
         """
-        return self.reallyRemove()
+        return self._reallyRemove()
 
 
     def removeNotifyCategory(self):

Modified: CalendarServer/trunk/txdav/common/datastore/sql_external.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_external.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/sql_external.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -132,7 +132,7 @@
         returnValue(child)
 
 
-    def removeChildWithName(self, name, bypassTrash=False):
+    def removeChildWithName(self, name, useTrash=True):
         """
         No children.
         """
@@ -147,7 +147,7 @@
         """
         if child._bindUID is None:
             raise AssertionError("CommonHomeExternal: not supported")
-        yield super(CommonHomeExternal, self).removeChildWithName(child.name(), bypassTrash=True)
+        yield super(CommonHomeExternal, self).removeChildWithName(child.name(), useTrash=False)
 
 
     def syncToken(self):
@@ -294,13 +294,13 @@
 
 
     @inlineCallbacks
-    def remove(self, bypassTrash=True):
+    def remove(self):
         """
         External shares are never removed directly - instead they must be "uninvited". However,
         the owner's external calendar can be removed.
         """
         if self.owned():
-            yield super(CommonHomeChildExternal, self).remove(bypassTrash=bypassTrash)
+            yield super(CommonHomeChildExternal, self).remove()
         else:
             raise AssertionError("CommonHomeChildExternal: not supported")
 

Modified: CalendarServer/trunk/txdav/common/datastore/sql_notification.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_notification.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/sql_notification.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -563,7 +563,7 @@
 
 
     @inlineCallbacks
-    def remove(self, bypassTrash=True):
+    def remove(self):
         """
         Remove DB rows corresponding to this notification home.
         """

Modified: CalendarServer/trunk/txdav/common/datastore/test/test_trash.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_trash.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_trash.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -794,7 +794,7 @@
         txn = self.store.newTransaction()
 
         resource = yield self._getResource(txn, "user02", trash2.name(), "")
-        yield resource.reallyRemove()
+        yield resource.purge()
 
         yield txn.commit()
 

Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/util.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -510,11 +510,11 @@
                     for name in ical.allowedStoreComponents:
                         yield home.removeCalendarWithName(
                             home._componentCalendarName[name],
-                            bypassTrash=True
+                            useTrash=False
                         )
                 else:
-                    yield home.removeCalendarWithName("calendar", bypassTrash=True)
-                yield home.removeCalendarWithName("inbox", bypassTrash=True)
+                    yield home.removeCalendarWithName("calendar", useTrash=False)
+                yield home.removeCalendarWithName("inbox", useTrash=False)
             except NoSuchHomeChildError:
                 pass
 

Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py	2015-04-09 18:46:46 UTC (rev 14671)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py	2015-04-10 17:57:10 UTC (rev 14672)
@@ -164,7 +164,7 @@
         # create orphans by deleting events
         cal = yield self.calendarUnderTest(home="user01", name="calendar")
         for item in (yield cal.objectResourcesWithNames(["cal1.ics", "cal3.ics"])):
-            yield item.remove(bypassTrash=True)
+            yield item.purge()
 
         # do cleanup
         yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=cal.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150410/6edd7ab8/attachment-0001.html>


More information about the calendarserver-changes mailing list