From: Antony Chazapis Date: Thu, 19 Apr 2012 16:02:09 +0000 (+0300) Subject: Calculate the length of the last block properly. X-Git-Tag: pithos/v0.9.5~3 X-Git-Url: https://code.grnet.gr/git/pithos/commitdiff_plain/45cf0bc8ac74de013ef07c7a22b6724328e5f5cb Calculate the length of the last block properly. Fixes #2321 --- diff --git a/snf-pithos-app/pithos/api/util.py b/snf-pithos-app/pithos/api/util.py index 4c4513c..7481ac3 100644 --- a/snf-pithos-app/pithos/api/util.py +++ b/snf-pithos-app/pithos/api/util.py @@ -661,7 +661,8 @@ class ObjectWrapper(object): # Get the data from the block. bo = self.offset % self.backend.block_size bs = self.backend.block_size - if self.block_index == len(self.hashmaps[self.file_index]) - 1: + if (self.block_index == len(self.hashmaps[self.file_index]) - 1 and + self.sizes[self.file_index] % self.backend.block_size): bs = self.sizes[self.file_index] % self.backend.block_size bl = min(self.length, bs - bo) data = self.block[bo:bo + bl]