[CalendarServer-changes] [2649] CalendarServer/branches/sqlpropstore-2629/twistedcaldav/upgrade.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 1 12:49:09 PDT 2008


Revision: 2649
          http://trac.macosforge.org/projects/calendarserver/changeset/2649
Author:   cdaboo at apple.com
Date:     2008-07-01 12:49:09 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Performance tweaks.

Modified Paths:
--------------
    CalendarServer/branches/sqlpropstore-2629/twistedcaldav/upgrade.py

Modified: CalendarServer/branches/sqlpropstore-2629/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/branches/sqlpropstore-2629/twistedcaldav/upgrade.py	2008-07-01 14:22:19 UTC (rev 2648)
+++ CalendarServer/branches/sqlpropstore-2629/twistedcaldav/upgrade.py	2008-07-01 19:49:09 UTC (rev 2649)
@@ -86,6 +86,14 @@
 
 class UpgradeXattrsToSqlite(object):
 
+    class DummyResource:
+        
+        def __init__(self, path):
+            self.fp = FilePath(path)
+    
+        def isCollection(self):
+            return self.fp.isdir()
+
     @classmethod
     def doUpgrade(cls):
         """
@@ -114,31 +122,33 @@
     @classmethod
     def _upgradeXAttrs(cls, docroot, path):
         
-        class DummyResource:
-            
-            def __init__(self, path):
-                self.fp = FilePath(path)
-        
-            def isCollection(self):
-                return self.fp.isdir()
-    
-        log.debug("Doing xattr->sqlite property upgrade for: %s" % (path,))
-        resource = DummyResource(os.path.join(docroot, path))
+        splits = path.split("/")
+        if len(splits) <= 5:
+            log.debug("Doing xattr->sqlite property upgrade for: %s" % (path,))
+
+        resource = cls.DummyResource(os.path.join(docroot, path))
         xprops = xattrPropertyStore(resource)
         
         # Detect some special cases for sql properties
         root_resource = (len(path) == 0)
-        avoid_contention = path.startswith("calendars/__uids__/") and len(path.split("/")) == 5
+        avoid_contention = path.startswith("calendars/__uids__/") and len(splits) == 5
         sqlprops = sqlPropertyStore(resource, root_resource=root_resource, avoid_contention=avoid_contention)
         
+        props = []
         for propname in list(xprops.list()):
             try:
-                sqlprops.set(xprops.get(propname))
+                props.append(xprops.get(propname))
             except Exception, e:
-                log.debug("Unable to upgrade property '%s' on '%s' because of %s" % (propname, path, e,))
+                log.debug("Unable to upgrade properties '%s' on '%s' because of %s" % (propname, path, e,))
             xprops.delete(propname)
 
+        if props:
+            try:
+                sqlprops._setSeveral(props)
+            except Exception, e:
+                log.debug("Unable to upgrade properties on '%s' because of %s" % (path, e,))
 
+
 class UpgradeError(RuntimeError):
     """
     Generic upgrade error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080701/06bd3923/attachment.html 


More information about the calendarserver-changes mailing list