From 0d4ea090b0b102b82b42124380df5b3351237594 Mon Sep 17 00:00:00 2001 From: Antony Chazapis Date: Fri, 9 Sep 2011 12:09:12 +0300 Subject: [PATCH] Fix computing hashmap hash. --- pithos/api/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pithos/api/util.py b/pithos/api/util.py index d51f7f4..8104e5d 100644 --- a/pithos/api/util.py +++ b/pithos/api/util.py @@ -35,7 +35,7 @@ from functools import wraps from time import time from traceback import format_exc from wsgiref.handlers import format_date_time -from binascii import hexlify +from binascii import hexlify, unhexlify from django.conf import settings from django.http import HttpResponse @@ -672,10 +672,12 @@ def hashmap_hash(hashmap): return hexlify(subhash('')) if len(hashmap) == 1: return hashmap[0] + s = 2 while s < len(hashmap): s = s * 2 - h = hashmap + ([('\x00' * len(hashmap[0]))] * (s - len(hashmap))) + h = [unhexlify(x) for x in hashmap] + h += [('\x00' * len(h[0]))] * (s - len(hashmap)) while len(h) > 1: h = [subhash(h[x] + h[x + 1]) for x in range(0, len(h), 2)] return hexlify(h[0]) -- 1.7.10.4