[CalendarServer-changes] [8721] CalendarServer/trunk/calendarserver/tools/purge.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 16 11:32:44 PST 2012


Revision: 8721
          http://trac.macosforge.org/projects/calendarserver/changeset/8721
Author:   sagen at apple.com
Date:     2012-02-16 11:32:43 -0800 (Thu, 16 Feb 2012)
Log Message:
-----------
When purging a principal, first try with implicit scheduling, then without.

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

Modified: CalendarServer/trunk/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/purge.py	2012-02-16 19:32:02 UTC (rev 8720)
+++ CalendarServer/trunk/calendarserver/tools/purge.py	2012-02-16 19:32:43 UTC (rev 8721)
@@ -18,6 +18,7 @@
 
 import os
 import sys
+import traceback
 from errno import ENOENT, EACCES
 from getopt import getopt, GetoptError
 
@@ -725,7 +726,7 @@
                             result = (yield storer.run())
 
                     elif action == CANCELEVENT_SHOULD_DELETE:
-                        count += 1
+                        incrementCount = dryrun
                         request._rememberResource(childResource, uri)
                         if verbose:
                             if dryrun:
@@ -733,11 +734,40 @@
                             else:
                                 print "Deleting: %s" % (uri,)
                         if not dryrun:
-                            result = (yield childResource.storeRemove(request, doimplicit, uri))
-                            if result != NO_CONTENT:
-                                print "Error deleting %s/%s/%s: %s" % (uid,
-                                    collName, childName, result)
+                            retry = False
+                            try:
+                                result = (yield childResource.storeRemove(request, doimplicit, uri))
+                                if result != NO_CONTENT:
+                                    print "Error deleting %s/%s/%s: %s" % (uid,
+                                        collName, childName, result)
+                                    retry = True
+                                else:
+                                    incrementCount = True
 
+                            except Exception, e:
+                                print "Exception deleting %s/%s/%s: %s" % (uid,
+                                    collName, childName, str(e))
+                                traceback.print_stack()
+                                retry = True
+
+                            if retry and doimplicit:
+                                # Try again with implicit scheduling off
+                                print "Retrying deletion of %s/%s/%s with implicit scheduling turned off" % (uid, collName, childName)
+                                try:
+                                    result = (yield childResource.storeRemove(request, False, uri))
+                                    if result != NO_CONTENT:
+                                        print "Error deleting %s/%s/%s: %s" % (uid,
+                                            collName, childName, result)
+                                    else:
+                                        incrementCount = True
+                                except Exception, e:
+                                    print "Still couldn't delete %s/%s/%s even with implicit scheduling turned off: %s" % (uid, collName, childName, str(e))
+                                    traceback.print_stack()
+
+                        if incrementCount:
+                            count += 1
+
+
         txn = request._newStoreTransaction
 
         # Remove empty calendar collections (and calendar home if no more
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120216/95d5d845/attachment-0001.html>


More information about the calendarserver-changes mailing list