[CalendarServer-changes] [2401] CalendarServer/branches/release/CalendarServer-1.3-dev/lib-patches/ Twisted/twisted.web2.dav.xattrprops.patch

source_changes at macosforge.org source_changes at macosforge.org
Fri May 9 10:41:34 PDT 2008


Revision: 2401
          http://trac.macosforge.org/projects/calendarserver/changeset/2401
Author:   wsanchez at apple.com
Date:     2008-05-09 10:41:34 -0700 (Fri, 09 May 2008)

Log Message:
-----------
Pulled up r2400: Fix legacy data logic and upgrade existing data.

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-1.3-dev/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch

Modified: CalendarServer/branches/release/CalendarServer-1.3-dev/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
===================================================================
--- CalendarServer/branches/release/CalendarServer-1.3-dev/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch	2008-05-09 17:40:37 UTC (rev 2400)
+++ CalendarServer/branches/release/CalendarServer-1.3-dev/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch	2008-05-09 17:41:34 UTC (rev 2401)
@@ -41,7 +41,7 @@
          return r
  
      def _decode(clazz, name):
-@@ -97,20 +96,51 @@
+@@ -97,20 +96,81 @@
  
      def get(self, qname):
          try:
@@ -54,26 +54,56 @@
              ))
  
 -        doc = davxml.WebDAVDocument.fromString(value)
++        #
++        # Serialize XML data to an xattr.  The storage format has
++        # changed over time:
++        #
++        #  1- Started with XML
++        #  2- Started compressing the XML due to limits on xattr size
++        #  3- Switched to pickle which is faster, still compressing
++        #
++        # We only write the current format, but we also read the old
++        # ones for compatibility.
++        #
++        legacy = False
+ 
+-        return doc.root_element
 +        try:
-+            return unpickle(decompress(data))
++            data = decompress(data)
++        except zlib.error:
++            legacy = True
+ 
++        try:
++            result = unpickle(data)
 +        except UnpicklingError:
++            legacy = True
++
 +            try:
-+                # Data is not pickled; try reading as compressed XML text
-+                value = decompress(data)
-+            except zlib.error:
-+                # Value is not compressed; try reading as XML text
-+                value = data
-+            del data
- 
--        return doc.root_element
-+            try:
-+                doc = davxml.WebDAVDocument.fromString(value)
-+                return doc.root_element
++                doc = davxml.WebDAVDocument.fromString(data)
++                result = doc.root_element
 +            except ValueError:
-+                msg = "Invalid property value stored on server: {%s}%s %s" % (qname[0], qname[1], value)
++                msg = ("Invalid property value stored on server: {%s}%s %s"
++                       % (qname[0], qname[1], data))
 +                log.err(msg)
 +                raise HTTPError(StatusResponse(responsecode.INTERNAL_SERVER_ERROR, msg))
- 
++
++        if legacy:
++            # Try to upgrade the property to the current format
++            try:
++                log.msg("Upgrading property %r on resource %r"
++                        % (qname, self.resource.fp.path))
++                self.set(result)
++            except Exception, e:
++                #
++                # Hrm, that failed.  No need to re-raise here, since
++                # we can do what we were asked to do, but let's
++                # complain about it.
++                #
++                log.err("Error while upgrading property %r on resource %r: %s"
++                        % (qname, self.resource.fp.path, e))
++
++        return result
++
      def set(self, property):
 -        self.attrs[self._encode(property.qname())] = property.toxml()
 +        for n in range(20):

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080509/1b8d0623/attachment-0001.html


More information about the calendarserver-changes mailing list