[CalendarServer-changes] [1930]
CalendarServer/trunk/twistedcaldav/admin/util.py
source_changes at macosforge.org
source_changes at macosforge.org
Sun Sep 30 19:55:44 PDT 2007
Revision: 1930
http://trac.macosforge.org/projects/calendarserver/changeset/1930
Author: cdaboo at apple.com
Date: 2007-09-30 19:55:43 -0700 (Sun, 30 Sep 2007)
Log Message:
-----------
Fix to ensure xattr values are decompressed as we now store them compressed.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/admin/util.py
Modified: CalendarServer/trunk/twistedcaldav/admin/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/util.py 2007-09-29 00:12:25 UTC (rev 1929)
+++ CalendarServer/trunk/twistedcaldav/admin/util.py 2007-10-01 02:55:43 UTC (rev 1930)
@@ -17,6 +17,7 @@
##
import xattr
+from zlib import decompress
import commands
@@ -98,7 +99,7 @@
type = None
- dom = microdom.parseString(x[rt])
+ dom = microdom.parseString(_getxattr_value(x, rt))
rt = microdom.getElementsByTagName(dom, 'resourcetype')
for child in rt[0].childNodes:
@@ -167,7 +168,7 @@
if not x.has_key(quotaRoot):
return None
- dom = microdom.parseString(x[quotaRoot])
+ dom = microdom.parseString(_getxattr_value(x, quotaRoot))
qr = microdom.getElementsByTagName(dom, 'quota-root')[0]
@@ -179,7 +180,7 @@
if not x.has_key(quotaUsed):
return None
- dom = microdom.parseString(x[quotaUsed])
+ dom = microdom.parseString(_getxattr_value(x, quotaUsed))
qu = microdom.getElementsByTagName(dom, 'quota-used')[0]
@@ -210,3 +211,14 @@
'quotaUsed': prepareByteValue(config, principalUsed),
'quotaAvail': prepareByteValue(config, principalAvail),
'quotaFree': principalFree}
+
+def _getxattr_value(x, k):
+ data = x[k]
+ try:
+ value = decompress(data)
+ except zlib.error:
+ # Value is not compressed; data was stored by old
+ # code. This is easy to handle, so let's keep
+ # compatibility here.
+ value = data
+ return value
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070930/da508f2c/attachment.html
More information about the calendarserver-changes
mailing list