Commit b1552049 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent bac7f527
...@@ -26,10 +26,12 @@ from six.moves.urllib_parse import urlsplit, urlunsplit ...@@ -26,10 +26,12 @@ from six.moves.urllib_parse import urlsplit, urlunsplit
from zlib import crc32, adler32 from zlib import crc32, adler32
from ZODB.TimeStamp import TimeStamp from ZODB.TimeStamp import TimeStamp
import dateparser import dateparser
from golang import b
def ashex(s): def ashex(s):
# type: (bytes) -> bytes # type: (bytes) -> bytes
return codecs.encode(s, 'hex') #return codecs.encode(s, 'hex')
return b(codecs.encode(s, 'hex')) # XXX ok?
def fromhex(s): def fromhex(s):
# type: (Union[str,bytes]) -> bytes # type: (Union[str,bytes]) -> bytes
......
...@@ -492,9 +492,10 @@ class ObjectCopy(Object): ...@@ -492,9 +492,10 @@ class ObjectCopy(Object):
# ObjectData represents record with object data. # ObjectData represents record with object data.
class ObjectData(Object): class ObjectData(Object):
# .data HashOnly | bytes # .data HashOnly | bytes
# .hashfunc bytes hash function used for integrity # .hashfunc bytes XXX hash function used for integrity
# .hash_ bytes hash of the object's data # .hash_ bytes hash of the object's data
def __init__(self, oid, data, hashfunc, hash_): def __init__(self, oid, data, hashfunc, hash_):
#assert isinstance(hashfunc, bytes)
super(ObjectData, self).__init__(oid) super(ObjectData, self).__init__(oid)
self.data = data self.data = data
self.hashfunc = hashfunc self.hashfunc = hashfunc
...@@ -507,7 +508,7 @@ class ObjectData(Object): ...@@ -507,7 +508,7 @@ class ObjectData(Object):
size = data.size size = data.size
else: else:
size = len(data) size = len(data)
z = b'obj %s %d %s:%s' % (ashex(self.oid), size, self.hashfunc, ashex(self.hash_)) z = b'obj %s %d %s:%s' % (ashex(self.oid), size, b(self.hashfunc), ashex(self.hash_))
if hashonly: if hashonly:
z += b' -' z += b' -'
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment