Revision c9865fe1 pithos/api/util.py
b/pithos/api/util.py | ||
---|---|---|
610 | 610 |
""" |
611 | 611 |
|
612 | 612 |
def __init__(self, backend, ranges, sizes, hashmaps, boundary): |
613 |
print '***', ranges, sizes, hashmaps, boundary |
|
613 | 614 |
self.backend = backend |
614 | 615 |
self.ranges = ranges |
615 | 616 |
self.sizes = sizes |
... | ... | |
648 | 649 |
|
649 | 650 |
# Get the data from the block. |
650 | 651 |
bo = self.offset % self.backend.block_size |
651 |
bl = min(self.length, len(self.block) - bo) |
|
652 |
bs = self.backend.block_size |
|
653 |
if self.block_index == len(self.hashmaps[self.file_index]) - 1: |
|
654 |
bs = self.sizes[self.file_index] % self.backend.block_size |
|
655 |
bl = min(self.length, bs - bo) |
|
652 | 656 |
data = self.block[bo:bo + bl] |
653 | 657 |
self.offset += bl |
654 | 658 |
self.length -= bl |
... | ... | |
753 | 757 |
md5 = hashlib.md5() |
754 | 758 |
bs = request.backend.block_size |
755 | 759 |
for bi, hash in enumerate(hashmap): |
756 |
data = request.backend.get_block(hash) |
|
760 |
data = request.backend.get_block(hash) # Blocks come in padded.
|
|
757 | 761 |
if bi == len(hashmap) - 1: |
758 |
bs = size % bs |
|
759 |
pad = bs - min(len(data), bs) |
|
760 |
md5.update(data + ('\x00' * pad)) |
|
762 |
data = data[:size % bs] |
|
763 |
md5.update(data) |
|
761 | 764 |
return md5.hexdigest().lower() |
762 | 765 |
|
763 | 766 |
def simple_list_response(request, l): |
Also available in: Unified diff