[CalendarServer-changes] [3768] CalendarServer/trunk/twistedcaldav/upgrade.py

source_changes at macosforge.org source_changes at macosforge.org
Sat Feb 28 09:28:17 PST 2009


Revision: 3768
          http://trac.macosforge.org/projects/calendarserver/changeset/3768
Author:   sagen at apple.com
Date:     2009-02-28 09:28:13 -0800 (Sat, 28 Feb 2009)
Log Message:
-----------
Get rid of the global variable

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/upgrade.py

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2009-02-28 02:54:21 UTC (rev 3767)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2009-02-28 17:28:13 UTC (rev 3768)
@@ -33,18 +33,14 @@
 log = Logger()
 
 
-
-
 #
 # upgrade_to_1
 #
 # Upconverts data from any calendar server version prior to data format 1
 #
-errorOccurred = False
 
 def upgrade_to_1(config):
 
-    global errorOccurred
     errorOccurred = False
 
     def fixBadQuotes(data):
@@ -93,8 +89,7 @@
 
     def upgradeCalendarCollection(calPath, directory):
 
-        global errorOccurred
-
+        errorOccurred = False
         collectionUpdated = False
 
         for resource in os.listdir(calPath):
@@ -151,15 +146,20 @@
             ctagValue = zlib.compress(ctagValue)
             xattr.setxattr(calPath, "WebDAV:{http:%2F%2Fcalendarserver.org%2Fns%2F}getctag", ctagValue)
 
+        return errorOccurred
 
+
     def upgradeCalendarHome(homePath, directory):
 
+        errorOccurred = False
+
         log.info("Upgrading calendar home: %s" % (homePath,))
 
         for cal in os.listdir(homePath):
             calPath = os.path.join(homePath, cal)
             log.info("Upgrading calendar: %s" % (calPath,))
-            upgradeCalendarCollection(calPath, directory)
+            if not upgradeCalendarCollection(calPath, directory):
+                errorOccurred = True
 
             # Change the calendar-free-busy-set xattrs of the inbox to the
             # __uids__/<guid> form
@@ -171,9 +171,9 @@
                             # Need to write the xattr back to disk
                             xattr.setxattr(calPath, attr, value)
 
+        return errorOccurred
 
 
-
     def doProxyDatabaseMoveUpgrade(config, uid=-1, gid=-1):
 
         # See if the old DB is present
@@ -310,7 +310,8 @@
                             secondPath = os.path.join(firstPath, second)
                             for home in os.listdir(secondPath):
                                 homePath = os.path.join(secondPath, home)
-                                upgradeCalendarHome(homePath, directory)
+                                if not upgradeCalendarHome(homePath, directory):
+                                    errorOccurred = True
 
     if errorOccurred:
         raise UpgradeError("Data upgrade failed, see error.log for details")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090228/0ba796bc/attachment.html>


More information about the calendarserver-changes mailing list