Calculate the length of the last block properly.
authorAntony Chazapis <chazapis@gmail.com>
Thu, 19 Apr 2012 16:02:09 +0000 (19:02 +0300)
committerAntony Chazapis <chazapis@gmail.com>
Thu, 19 Apr 2012 16:02:09 +0000 (19:02 +0300)
Fixes #2321

snf-pithos-app/pithos/api/util.py

index 4c4513c..7481ac3 100644 (file)
@@ -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]