storageserver: the last segment is not always going to be the same size as the rest...
authorBrian Warner <warner@allmydata.com>
Tue, 17 Apr 2007 20:41:45 +0000 (13:41 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 17 Apr 2007 20:41:45 +0000 (13:41 -0700)
src/allmydata/storageserver.py

index 136c5dc56402e2ea88838f7ba6b0372f420697dd..1cdea75aff56cb48beb341bf7f5d8d135701e501 100644 (file)
@@ -38,7 +38,10 @@ class BucketWriter(Referenceable):
 
     def remote_put_block(self, segmentnum, data):
         precondition(not self.closed)
-        assert len(data) == self.blocksize
+        # all blocks but the last will be of size self.blocksize, however the
+        # last one may be short, and we don't know the total number of
+        # segments so we can't tell which is which.
+        assert len(data) <= self.blocksize
         f = open(os.path.join(self.incominghome, 'data'), 'wb')
         f.seek(self.blocksize*segmentnum)
         f.write(data)