[CalendarServer-changes] [9253] CalendarServer/trunk/calendarserver/tools/obliterate.py

source_changes at macosforge.org source_changes at macosforge.org
Thu May 17 13:31:43 PDT 2012


Revision: 9253
          http://trac.macosforge.org/projects/calendarserver/changeset/9253
Author:   cdaboo at apple.com
Date:     2012-05-17 13:31:43 -0700 (Thu, 17 May 2012)
Log Message:
-----------
Clean up unused import. Handle foreign key reference for shared to someone else calendar.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/obliterate.py

Modified: CalendarServer/trunk/calendarserver/tools/obliterate.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/obliterate.py	2012-05-17 17:54:21 UTC (rev 9252)
+++ CalendarServer/trunk/calendarserver/tools/obliterate.py	2012-05-17 20:31:43 UTC (rev 9253)
@@ -15,7 +15,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-import time
 
 """
 This tool scans wipes out user data without using slow store object apis
@@ -38,7 +37,7 @@
 from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
 import os
 import sys
-import uuid
+import time
 
 VERSION = "1"
 
@@ -334,7 +333,7 @@
 
         # Remove revisions - do before deleting calendars to remove
         # foreign key constraint
-        yield self.removeRevisionsForResourceID(homeID)
+        yield self.removeRevisionsForHomeResourceID(homeID)
 
         # Look at each calendar and unbind/delete-if-owned
         count = (yield self.deleteCalendars(homeID))
@@ -409,6 +408,9 @@
     @inlineCallbacks
     def deleteCalendar(self, resourceID):
 
+        # Need to delete any remaining CALENDAR_OBJECT_REVISIONS entries
+        yield self.removeRevisionsForCalendarResourceID(resourceID)
+
         # Delete the CALENDAR entry (will cascade to CALENDAR_BIND and CALENDAR_OBJECT)
         if not self.options["dry-run"]:
             ca = schema.CALENDAR
@@ -444,7 +446,7 @@
 
 
     @inlineCallbacks
-    def removeRevisionsForResourceID(self, resourceID):
+    def removeRevisionsForHomeResourceID(self, resourceID):
         if not self.options["dry-run"]:
             rev = schema.CALENDAR_OBJECT_REVISIONS
             kwds = { "ResourceID" : resourceID }
@@ -457,6 +459,19 @@
 
 
     @inlineCallbacks
+    def removeRevisionsForCalendarResourceID(self, resourceID):
+        if not self.options["dry-run"]:
+            rev = schema.CALENDAR_OBJECT_REVISIONS
+            kwds = { "ResourceID" : resourceID }
+            yield Delete(
+                From=rev,
+                Where=(
+                    rev.CALENDAR_RESOURCE_ID == Parameter("ResourceID")
+                ),
+            ).on(self.txn, **kwds)
+
+
+    @inlineCallbacks
     def removePropertiesForResourceID(self, resourceID):
         if not self.options["dry-run"]:
             props = schema.RESOURCE_PROPERTY
@@ -557,10 +572,6 @@
         Stop the service.  Nothing to do; everything should be finished by this
         time.
         """
-        # TODO: stopping this service mid-export should really stop the export
-        # loop, but this is not implemented because nothing will actually do it
-        # except hitting ^C (which also calls reactor.stop(), so that will exit
-        # anyway).
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120517/a7ee2659/attachment.html>


More information about the calendarserver-changes mailing list