]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/commitdiff
TEMP TFIX EASYFGEC
authorzooko <zooko@zooko.com>
Thu, 8 Nov 2007 22:28:06 +0000 (03:58 +0530)
committerzooko <zooko@zooko.com>
Thu, 8 Nov 2007 22:28:06 +0000 (03:58 +0530)
darcs-hash:51a43555f1cf5d12bd8602254a17b0596d590e7d

zfec/zfec/easyfec.py

index 1843a69730de8d34e59228be1df6c688e9cd25c2..8b5e8965f4a5c64181eb403d2d40b09ccd32d506 100644 (file)
@@ -19,11 +19,11 @@ class Encoder(object):
         @param data: string
         """
         chunksize = div_ceil(len(data), self.fec.k)
-        numchunks = div_ceil(len(data), chunksize)
-        l = [ data[i:i+chunksize] for i in range(0, len(data), chunksize) ]
+        l = [ data[i*chunksize:(i+1)*chunksize] for i in range(self.fec.k) ]
         # padding
-        if len(l[-1]) != len(l[0]):
-            l[-1] = l[-1] + ('\x00'*(len(l[0])-len(l[-1])))
+        if l and (len(l[-1]) != chunksize):
+            l[-1] = l[-1] + ('\x00'*(chunksize-len(l[-1])))
+        assert len(l) == self.fec.k, (len(l), self.fec.k,)
         res = self.fec.encode(l)
         return res