<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14633] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14633">14633</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2015-03-30 09:19:36 -0700 (Mon, 30 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Purge tool bypasses the trash</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertoolscalverifypy">CalendarServer/trunk/calendarserver/tools/calverify.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolspurgepy">CalendarServer/trunk/calendarserver/tools/purge.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoreschedulingutilspy">CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresql_externalpy">CalendarServer/trunk/txdav/caldav/datastore/sql_external.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretestcommonpy">CalendarServer/trunk/txdav/caldav/datastore/test/common.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_attachmentspy">CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcarddavdatastoresqlpy">CalendarServer/trunk/txdav/carddav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorefilepy">CalendarServer/trunk/txdav/common/datastore/file.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingmigrationtesttest_home_syncpy">CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_externalpy">CalendarServer/trunk/txdav/common/datastore/sql_external.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_notificationpy">CalendarServer/trunk/txdav/common/datastore/sql_notification.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoretestutilpy">CalendarServer/trunk/txdav/common/datastore/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreworktesttest_inbox_cleanuppy">CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertoolscalverifypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/calverify.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/calverify.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/calendarserver/tools/calverify.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -739,7 +739,7 @@
</span><span class="cx">             calendar = yield home.childWithID(calendarID)
</span><span class="cx">             calendarObj = yield calendar.objectResourceWithID(resid)
</span><span class="cx">             objname = calendarObj.name()
</span><del>-            yield calendarObj.remove(implicitly=False)
</del><ins>+            yield calendarObj.remove(implicitly=False, bypassTrash=True)
</ins><span class="cx">             yield self.txn.commit()
</span><span class="cx">             self.txn = self.store.newTransaction()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolspurgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/purge.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/purge.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/calendarserver/tools/purge.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -994,7 +994,7 @@
</span><span class="cx">             yield storeCalHome.removeUnacceptedShares()
</span><span class="cx">             notificationHome = yield txn.notificationsWithUID(storeCalHome.uid())
</span><span class="cx">             if notificationHome is not None:
</span><del>-                yield notificationHome.remove()
</del><ins>+                yield notificationHome.remove(bypassTrash=True)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -1059,7 +1059,7 @@
</span><span class="cx">                     if not self.dryrun:
</span><span class="cx">                         retry = False
</span><span class="cx">                         try:
</span><del>-                            yield childResource.remove(implicitly=doScheduling)
</del><ins>+                            yield childResource.remove(implicitly=doScheduling, bypassTrash=True)
</ins><span class="cx">                             incrementCount = True
</span><span class="cx">                         except Exception, e:
</span><span class="cx">                             print(&quot;Exception deleting %s: %s&quot; % (uri, str(e)))
</span><span class="lines">@@ -1069,7 +1069,7 @@
</span><span class="cx">                             # Try again with implicit scheduling off
</span><span class="cx">                             print(&quot;Retrying deletion of %s with scheduling turned off&quot; % (uri,))
</span><span class="cx">                             try:
</span><del>-                                yield childResource.remove(implicitly=False)
</del><ins>+                                yield childResource.remove(implicitly=False, bypassTrash=True)
</ins><span class="cx">                                 incrementCount = True
</span><span class="cx">                             except Exception, e:
</span><span class="cx">                                 print(&quot;Still couldn't delete %s even with scheduling turned off: %s&quot; % (uri, str(e)))
</span><span class="lines">@@ -1099,6 +1099,7 @@
</span><span class="cx">             storeCalHome = yield txn.calendarHomeWithUID(uid)
</span><span class="cx">             if storeCalHome is not None:
</span><span class="cx">                 calendars = list((yield storeCalHome.calendars()))
</span><ins>+                calendars.extend(list((yield storeCalHome.calendars(onlyInTrash=True))))
</ins><span class="cx">                 remainingCalendars = len(calendars)
</span><span class="cx">                 for calColl in calendars:
</span><span class="cx">                     if len(list((yield calColl.calendarObjects()))) == 0:
</span><span class="lines">@@ -1111,7 +1112,7 @@
</span><span class="cx">                                 print(&quot;Deleting calendar: %s&quot; % (calendarName,))
</span><span class="cx">                         if not self.dryrun:
</span><span class="cx">                             if calColl.owned():
</span><del>-                                yield storeCalHome.removeChildWithName(calendarName)
</del><ins>+                                yield storeCalHome.removeChildWithName(calendarName, bypassTrash=True)
</ins><span class="cx">                             else:
</span><span class="cx">                                 yield calColl.unshare()
</span><span class="cx"> 
</span><span class="lines">@@ -1178,7 +1179,7 @@
</span><span class="cx">                     if not self.dryrun:
</span><span class="cx">                         # Also remove the addressbook collection itself
</span><span class="cx">                         if abColl.owned():
</span><del>-                            yield storeAbHome.removeChildWithName(abName)
</del><ins>+                            yield storeAbHome.removeChildWithName(abName, bypassTrash=True)
</ins><span class="cx">                         else:
</span><span class="cx">                             yield abColl.unshare()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingprocessingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -969,7 +969,7 @@
</span><span class="cx">         @type name: C{str}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL)
</del><ins>+        yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def resetAttendeePartstat(self, component, cuas, partstat, hadRSVP=False):
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoreschedulingutilspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/utils.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx">             # Delete all but the first one
</span><span class="cx">             log.debug(&quot;Should only have zero or one scheduling object resource with UID '%s' in calendar home: %s&quot; % (uid, calendar_home,))
</span><span class="cx">             for resource in objectResources[1:]:
</span><del>-                yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL)
</del><ins>+                yield resource._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
</ins><span class="cx">             objectResources = objectResources[:1]
</span><span class="cx"> 
</span><span class="cx">         returnValue(objectResources[0] if len(objectResources) == 1 else None)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -519,8 +519,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def calendars(self):
-        returnValue([c for c in (yield self.children()) if not c.isTrash()])
</del><ins>+    def calendars(self, onlyInTrash=False):
+        if onlyInTrash:
+            returnValue([c for c in (yield self.children()) if c.isTrash()])
+        else:
+            returnValue([c for c in (yield self.children()) if not c.isTrash()])
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -1314,7 +1317,7 @@
</span><span class="cx"> 
</span><span class="cx">         if child is None:
</span><span class="cx">             child = yield self.objectResourceWithID(rid)
</span><del>-        yield child._removeInternal(internal_state=ComponentRemoveState.INTERNAL)
</del><ins>+        yield child._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def calendarObjectsInTimeRange(self, start, end, timeZone):
</span><span class="lines">@@ -3529,7 +3532,7 @@
</span><span class="cx"> 
</span><span class="cx">                     # Now forcibly delete the event
</span><span class="cx">                     if not inserting:
</span><del>-                        yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL)
</del><ins>+                        yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
</ins><span class="cx">                         raise ResourceDeletedError(&quot;Resource modified but immediately deleted by the server.&quot;)
</span><span class="cx">                     else:
</span><span class="cx">                         raise AttendeeAllowedError(&quot;Attendee cannot create event for Organizer: {0}&quot;.format(implicit_result,))
</span><span class="lines">@@ -4103,9 +4106,10 @@
</span><span class="cx">         return succeed(None)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def remove(self, implicitly=True):
</del><ins>+    def remove(self, implicitly=True, bypassTrash=False):
</ins><span class="cx">         return self._removeInternal(
</span><del>-            internal_state=ComponentRemoveState.NORMAL if implicitly else ComponentRemoveState.NORMAL_NO_IMPLICIT
</del><ins>+            internal_state=ComponentRemoveState.NORMAL if implicitly else ComponentRemoveState.NORMAL_NO_IMPLICIT,
+            bypassTrash=bypassTrash
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -4114,12 +4118,14 @@
</span><span class="cx">         Do a &quot;silent&quot; removal of this object resource.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         return self._removeInternal(
</span><del>-            ComponentRemoveState.NORMAL_NO_IMPLICIT
</del><ins>+            ComponentRemoveState.NORMAL_NO_IMPLICIT, bypassTrash=True
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def _removeInternal(self, internal_state=ComponentRemoveState.NORMAL):
</del><ins>+    def _removeInternal(
+        self, internal_state=ComponentRemoveState.NORMAL, bypassTrash=False
+    ):
</ins><span class="cx"> 
</span><span class="cx">         isinbox = self._calendar.isInbox()
</span><span class="cx"> 
</span><span class="lines">@@ -4144,20 +4150,21 @@
</span><span class="cx">                 yield DropBoxAttachment.resourceRemoved(self._txn, self._resourceID, self._dropboxID)
</span><span class="cx">             yield ManagedAttachment.resourceRemoved(self._txn, self._resourceID)
</span><span class="cx"> 
</span><del>-        if isinbox: # bypass the trash
-            yield super(CalendarObject, self).reallyRemove()
</del><ins>+        if isinbox:
+            bypassTrash = True
</ins><span class="cx">         else:
</span><span class="cx">             calendar = (yield self.componentForUser())
</span><span class="cx">             status = calendar.mainComponent().getProperty(&quot;STATUS&quot;)
</span><span class="cx">             if status is not None:
</span><span class="cx">                 status = status.strvalue()
</span><span class="cx">                 if status == &quot;CANCELLED&quot;:
</span><del>-                    yield super(CalendarObject, self).reallyRemove()
-                else:
-                    yield super(CalendarObject, self).remove()
-            else:
-                yield super(CalendarObject, self).remove()
</del><ins>+                    bypassTrash = True
</ins><span class="cx"> 
</span><ins>+        if bypassTrash:
+            yield super(CalendarObject, self).reallyRemove()
+        else:
+            yield super(CalendarObject, self).remove()
+
</ins><span class="cx">         # Do scheduling
</span><span class="cx">         if scheduler is not None:
</span><span class="cx">             # Cannot do implicit in sharee's shared calendar
</span><span class="lines">@@ -5039,7 +5046,7 @@
</span><span class="cx">             yield self._setComponentInternal(ical_new, internal_state=ComponentUpdateState.SPLIT_ATTENDEE)
</span><span class="cx">         else:
</span><span class="cx">             # The split removed all components from this object - remove it
</span><del>-            yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL)
</del><ins>+            yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL, bypassTrash=True)
</ins><span class="cx"> 
</span><span class="cx">         # Create a new resource and store its data (but not if the parent is &quot;inbox&quot;, or if it is empty)
</span><span class="cx">         if not self.calendar().isInbox() and ical_old.mainType() is not None:
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresql_externalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql_external.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql_external.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql_external.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -218,7 +218,9 @@
</span><span class="cx">         raise AssertionError(&quot;CalendarObjectExternal: not supported&quot;)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def _removeInternal(self, internal_state=ComponentRemoveState.NORMAL):
</del><ins>+    def _removeInternal(
+        self, internal_state=ComponentRemoveState.NORMAL, bypassTrash=False
+    ):
</ins><span class="cx">         raise AssertionError(&quot;CalendarObjectExternal: not supported&quot;)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretestcommonpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -756,6 +756,7 @@
</span><span class="cx">         exists.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         home = yield self.homeUnderTest()
</span><ins>+        trash = yield home.getTrash(create=True)
</ins><span class="cx"> 
</span><span class="cx">         # FIXME: test transactions
</span><span class="cx">         for name in home1_calendarNames:
</span><span class="lines">@@ -766,14 +767,20 @@
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         # Make sure notification fired after commit
</span><ins>+        expected = [
+            (&quot;/CalDAV/example.com/home1/&quot;, PushPriority.high),
+            (&quot;/CalDAV/example.com/home1/calendar_1/&quot;, PushPriority.high),
+            (&quot;/CalDAV/example.com/home1/calendar_2/&quot;, PushPriority.high),
+            (&quot;/CalDAV/example.com/home1/calendar_empty/&quot;, PushPriority.high),
+        ]
+        if trash:
+            expected.append(
+                (&quot;/CalDAV/example.com/home1/{}/&quot;.format(trash.name()), PushPriority.high),
+            )
+
</ins><span class="cx">         self.assertEquals(
</span><span class="cx">             set(self.notifierFactory.history),
</span><del>-            set([
-                (&quot;/CalDAV/example.com/home1/&quot;, PushPriority.high),
-                (&quot;/CalDAV/example.com/home1/calendar_1/&quot;, PushPriority.high),
-                (&quot;/CalDAV/example.com/home1/calendar_2/&quot;, PushPriority.high),
-                (&quot;/CalDAV/example.com/home1/calendar_empty/&quot;, PushPriority.high),
-            ])
</del><ins>+            set(expected)
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -876,7 +883,7 @@
</span><span class="cx">         ctxn = self.concurrentTransaction()
</span><span class="cx">         calendar1prime = yield self.calendarUnderTest(ctxn)
</span><span class="cx">         obj1 = yield calendar1prime.calendarObjectWithName(&quot;1.ics&quot;)
</span><del>-        yield obj1.remove()
</del><ins>+        yield obj1.remove(bypassTrash=True)
</ins><span class="cx">         yield ctxn.commit()
</span><span class="cx">         try:
</span><span class="cx">             retrieval = yield calendarObject.component()
</span><span class="lines">@@ -927,6 +934,8 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Remove an existing calendar object.
</span><span class="cx">         &quot;&quot;&quot;
</span><ins>+        home = yield self.homeUnderTest()
+        trash = yield home.getTrash(create=True)
</ins><span class="cx">         calendar = yield self.calendarUnderTest()
</span><span class="cx">         for name in calendar1_objectNames:
</span><span class="cx">             uid = (u'uid' + name.rstrip(&quot;.ics&quot;))
</span><span class="lines">@@ -942,13 +951,18 @@
</span><span class="cx">                 None
</span><span class="cx">             )
</span><span class="cx"> 
</span><ins>+        expected = [
+            (&quot;/CalDAV/example.com/home1/&quot;, PushPriority.high),
+            (&quot;/CalDAV/example.com/home1/calendar_1/&quot;, PushPriority.high),
+        ]
+        if trash:
+            expected.append(
+                (&quot;/CalDAV/example.com/home1/{}/&quot;.format(trash.name()), PushPriority.high),
+            )
</ins><span class="cx">         # notify is called prior to commit
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             set(self.notifierFactory.history),
</span><del>-            set([
-                (&quot;/CalDAV/example.com/home1/&quot;, PushPriority.high),
-                (&quot;/CalDAV/example.com/home1/calendar_1/&quot;, PushPriority.high),
-            ])
</del><ins>+            set(expected)
</ins><span class="cx">         )
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="lines">@@ -1610,13 +1624,25 @@
</span><span class="cx"> 
</span><span class="cx">         home = yield self.homeUnderTest()
</span><span class="cx"> 
</span><ins>+        expected = [
+            &quot;calendar_1/&quot;,
+            &quot;calendar_1/new.ics&quot;,
+            &quot;calendar_1/2.ics&quot;,
+            &quot;other-calendar/&quot;
+        ]
+
+        trash = yield home.getTrash()
+        if trash is not None:
+            trashed = yield trash.calendarObjects()
+            expected.extend([
+                &quot;{}/&quot;.format(trash.name()),
+                &quot;{}/{}&quot;.format(trash.name(), trashed[0].name()),
+            ])
+
</ins><span class="cx">         changed, deleted, invalid = yield home.resourceNamesSinceToken(
</span><span class="cx">             self.token2revision(st), &quot;infinity&quot;)
</span><span class="cx"> 
</span><del>-        self.assertEquals(set(changed), set([&quot;calendar_1/&quot;,
-                                             &quot;calendar_1/new.ics&quot;,
-                                             &quot;calendar_1/2.ics&quot;,
-                                             &quot;other-calendar/&quot;]))
</del><ins>+        self.assertEquals(set(changed), set(expected))
</ins><span class="cx">         self.assertEquals(set(deleted), set([&quot;calendar_1/2.ics&quot;]))
</span><span class="cx">         self.assertEquals(invalid, [])
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_attachmentspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -818,7 +818,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Remove resource
</span><span class="cx">         obj = yield self.calendarObjectUnderTest()
</span><del>-        yield obj.remove()
</del><ins>+        yield obj.remove(bypassTrash=True)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         self.assertTrue(os.path.exists(apath))
</span><span class="lines">@@ -830,7 +830,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Remove resource
</span><span class="cx">         obj = yield self.calendarObjectUnderTest(name=&quot;test.ics&quot;)
</span><del>-        yield obj.remove()
</del><ins>+        yield obj.remove(bypassTrash=True)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         self.assertFalse(os.path.exists(apath))
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -827,7 +827,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Remove calendar and check for no properties
</span><span class="cx">         home = yield self.homeUnderTest()
</span><del>-        yield home.removeCalendarWithName(name)
</del><ins>+        yield home.removeCalendarWithName(name, bypassTrash=True)
</ins><span class="cx">         rows = yield _allWithID.on(self.transactionUnderTest(), resourceID=resourceID)
</span><span class="cx">         self.assertEqual(len(tuple(rows)), 0)
</span><span class="cx">         yield self.commit()
</span><span class="lines">@@ -1218,7 +1218,7 @@
</span><span class="cx">         home = yield self.transactionUnderTest().calendarHomeWithUID(&quot;home_defaults&quot;)
</span><span class="cx">         self.assertEqual(home._default_events, default_events._resourceID)
</span><span class="cx">         self.assertEqual(home._default_tasks, default_tasks._resourceID)
</span><del>-        yield home.removeCalendarWithName(&quot;calendar_1-vtodo&quot;)
</del><ins>+        yield home.removeCalendarWithName(&quot;calendar_1-vtodo&quot;, bypassTrash=True)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         home = yield self.transactionUnderTest().calendarHomeWithUID(&quot;home_defaults&quot;)
</span><span class="lines">@@ -1295,7 +1295,7 @@
</span><span class="cx"> 
</span><span class="cx">         home = yield self.homeUnderTest(name=&quot;home_defaults&quot;)
</span><span class="cx">         calendar1 = yield home.calendarWithName(&quot;calendar_1&quot;)
</span><del>-        yield calendar1.remove()
</del><ins>+        yield calendar1.remove(bypassTrash=True)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         home = yield self.homeUnderTest(name=&quot;home_defaults&quot;)
</span><span class="lines">@@ -3613,7 +3613,7 @@
</span><span class="cx">         yield self.abort()
</span><span class="cx"> 
</span><span class="cx">         cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</span><del>-        yield cobj.remove()
</del><ins>+        yield cobj.remove(bypassTrash=True)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         rows = yield Select(
</span></span></pre></div>
<a id="CalendarServertrunktxdavcarddavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/carddav/datastore/sql.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/carddav/datastore/sql.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/carddav/datastore/sql.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -888,7 +888,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def remove(self):
</del><ins>+    def remove(self, bypassTrash=True):
</ins><span class="cx"> 
</span><span class="cx">         if self._resourceID == self._home._resourceID:
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorefilepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/file.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/file.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/file.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -848,7 +848,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @writeOperation
</span><del>-    def removeChildWithName(self, name):
</del><ins>+    def removeChildWithName(self, name, bypassTrash=False):
</ins><span class="cx">         if name.startswith(&quot;.&quot;) or name in self._removedChildren:
</span><span class="cx">             raise NoSuchHomeChildError(name)
</span><span class="cx"> 
</span><span class="lines">@@ -865,6 +865,10 @@
</span><span class="cx">                 self._removedChildren.add(name)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def getTrash(self, create=False):
+        return succeed(None)
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def syncToken(self):
</span><span class="cx"> 
</span><span class="lines">@@ -1399,7 +1403,7 @@
</span><span class="cx">         raise NotImplementedError
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def remove(self):
</del><ins>+    def remove(self, bypassTrash=False):
</ins><span class="cx"> 
</span><span class="cx">         # FIXME: test for undo
</span><span class="cx">         objectResourcePath = self._path
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingmigrationtesttest_home_syncpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/podding/migration/test/test_home_sync.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -552,7 +552,7 @@
</span><span class="cx">         home0 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(0), name=&quot;user01&quot;, create=True)
</span><span class="cx">         calendar0 = yield home0.childWithName(&quot;new-calendar&quot;)
</span><span class="cx">         del details0[calendar0.id()]
</span><del>-        yield calendar0.remove()
</del><ins>+        yield calendar0.remove(bypassTrash=True)
</ins><span class="cx">         yield self.commitTransaction(0)
</span><span class="cx"> 
</span><span class="cx">         # Trigger sync
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -1088,7 +1088,7 @@
</span><span class="cx">             home = (yield self.calendarHomeWithUID(uid))
</span><span class="cx">             calendar = (yield home.childWithName(calendarName))
</span><span class="cx">             resource = (yield calendar.objectResourceWithName(eventName))
</span><del>-            yield resource.remove(implicitly=False)
</del><ins>+            yield resource.remove(implicitly=False, bypassTrash=True)
</ins><span class="cx">             count += 1
</span><span class="cx">         returnValue(count)
</span><span class="cx"> 
</span><span class="lines">@@ -2308,14 +2308,14 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def removeChildWithName(self, name):
</del><ins>+    def removeChildWithName(self, name, bypassTrash=False):
</ins><span class="cx">         child = yield self.childWithName(name)
</span><span class="cx">         if child is None:
</span><span class="cx">             raise NoSuchHomeChildError()
</span><span class="cx">         key = self._childrenKey(child.isInTrash())
</span><span class="cx">         resourceID = child._resourceID
</span><span class="cx"> 
</span><del>-        yield child.remove()
</del><ins>+        yield child.remove(bypassTrash=bypassTrash)
</ins><span class="cx">         self._children[key].pop(name, None)
</span><span class="cx">         self._children[key].pop(resourceID, None)
</span><span class="cx"> 
</span><span class="lines">@@ -3455,7 +3455,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def remove(self):
</del><ins>+    def remove(self, bypassTrash=False):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Just moves the collection to the trash
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -3465,7 +3465,10 @@
</span><span class="cx">             if isInTrash:
</span><span class="cx">                 raise AlreadyInTrashError
</span><span class="cx">             else:
</span><del>-                yield self.toTrash()
</del><ins>+                if bypassTrash:
+                    yield self.reallyRemove()
+                else:
+                    yield self.toTrash()
</ins><span class="cx">         else:
</span><span class="cx">             yield self.reallyRemove()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_externalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_external.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_external.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/sql_external.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -132,7 +132,7 @@
</span><span class="cx">         returnValue(child)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def removeChildWithName(self, name):
</del><ins>+    def removeChildWithName(self, name, bypassTrash=False):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         No children.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -147,7 +147,7 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if child._bindUID is None:
</span><span class="cx">             raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
</span><del>-        yield super(CommonHomeExternal, self).removeChildWithName(child.name())
</del><ins>+        yield super(CommonHomeExternal, self).removeChildWithName(child.name(), bypassTrash=True)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def syncToken(self):
</span><span class="lines">@@ -294,13 +294,13 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def remove(self):
</del><ins>+    def remove(self, bypassTrash=True):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         External shares are never removed directly - instead they must be &quot;uninvited&quot;. However,
</span><span class="cx">         the owner's external calendar can be removed.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if self.owned():
</span><del>-            yield super(CommonHomeChildExternal, self).remove()
</del><ins>+            yield super(CommonHomeChildExternal, self).remove(bypassTrash=bypassTrash)
</ins><span class="cx">         else:
</span><span class="cx">             raise AssertionError(&quot;CommonHomeChildExternal: not supported&quot;)
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_notificationpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_notification.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_notification.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/sql_notification.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -563,7 +563,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def remove(self):
</del><ins>+    def remove(self, bypassTrash=True):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Remove DB rows corresponding to this notification home.
</span><span class="cx">         &quot;&quot;&quot;
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/test/util.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/test/util.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/test/util.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -509,11 +509,12 @@
</span><span class="cx">                 if config.RestrictCalendarsToOneComponentType:
</span><span class="cx">                     for name in ical.allowedStoreComponents:
</span><span class="cx">                         yield home.removeCalendarWithName(
</span><del>-                            home._componentCalendarName[name]
</del><ins>+                            home._componentCalendarName[name],
+                            bypassTrash=True
</ins><span class="cx">                         )
</span><span class="cx">                 else:
</span><del>-                    yield home.removeCalendarWithName(&quot;calendar&quot;)
-                yield home.removeCalendarWithName(&quot;inbox&quot;)
</del><ins>+                    yield home.removeCalendarWithName(&quot;calendar&quot;, bypassTrash=True)
+                yield home.removeCalendarWithName(&quot;inbox&quot;, bypassTrash=True)
</ins><span class="cx">             except NoSuchHomeChildError:
</span><span class="cx">                 pass
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreworktesttest_inbox_cleanuppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py (14632 => 14633)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py        2015-03-29 05:57:59 UTC (rev 14632)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_inbox_cleanup.py        2015-03-30 16:19:36 UTC (rev 14633)
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx">         # create orphans by deleting events
</span><span class="cx">         cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
</span><span class="cx">         for item in (yield cal.objectResourcesWithNames([&quot;cal1.ics&quot;, &quot;cal3.ics&quot;])):
</span><del>-            yield item.remove()
</del><ins>+            yield item.remove(bypassTrash=True)
</ins><span class="cx"> 
</span><span class="cx">         # do cleanup
</span><span class="cx">         yield self.transactionUnderTest().enqueue(CleanupOneInboxWork, homeID=cal.ownerHome()._resourceID, notBefore=datetime.datetime.utcnow())
</span></span></pre>
</div>
</div>

</body>
</html>