]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
pyfec: add documentation, assertion, licence information
authorZooko O'Whielacronx <zooko@zooko.com>
Wed, 28 Mar 2007 03:14:06 +0000 (20:14 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Wed, 28 Mar 2007 03:14:06 +0000 (20:14 -0700)
pyfec/fec/_fecmodule.c
pyfec/fec/filefec.py

index 97a935e4815d3423fa0e941283eb2fc39a768b5b..a3497c8bb3a169ac6bfbdf6d79362a5c8904c154 100644 (file)
@@ -125,8 +125,9 @@ Encoder_init(Encoder *self, PyObject *args, PyObject *kwdict) {
 }
 
 static char Encoder_encode__doc__[] = "\
-Encode data into m packets.\
-@param inshares: a sequence of k buffers of data to encode -- these are the k primary shares, i.e. the input data split into k pieces (for best performance, make it a tuple instead of a list)\n\
+Encode data into m packets.\n\
+\n\
+@param inshares: a sequence of k buffers of data to encode -- these are the k primary shares, i.e. the input data split into k pieces (for best performance, make it a tuple instead of a list);  All shares are required to be the same length.\n\
 @param desired_shares_ids optional sequence of shareids indicating which shares to produce and return;  If None, all m shares will be returned (in order).  (For best performance, make it a tuple instead of a list.)\n\
 @returns: a list of buffers containing the requested shares; Note that if any of the input shares were 'primary shares', i.e. their shareid was < k, then the result sequence will contain a Python reference to the same Python object as was passed in.  As long as the Python object in question is immutable (i.e. a string) then you don't have to think about this detail, but if it is mutable (i.e. an array), then you have to be aware that if you subsequently mutate the contents of that object then that will also change the contents of the sequence that was returned from this call to encode().\n\
 ";
index 4899eded3749690061c0cbbc65fb72ba1960bdc7..a4736f5e36d857e41e024a879434efec6af9a60a 100644 (file)
@@ -6,10 +6,13 @@
 # 
 # This file is part of pyfec.
 # 
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.  This program also comes with the added permission that,
+# in the case that you are obligated to release a derived work under this
+# licence (as per section 2.b of the GPL), you may delay the fulfillment of
+# this obligation for up to 12 months.
 # 
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,9 +62,12 @@ def decode_from_files(outf, filesize, prefix, k, m):
         x = [ inf.read(CHUNKSIZE) for inf in infs ]
         decshares = dec.decode(x, shareids)
         for decshare in decshares:
+            if len(decshare) == 0:
+                raise "error -- probably share was too short -- was it stored in a file which got truncated? chunksizes: %s" % ([len(chunk) for chunk in x],)
             if filesize >= len(decshare):
                 outf.write(decshare)
                 filesize -= len(decshare)
+                # print "filesize is now %s after subtracting %s" % (filesize, len(decshare),)
             else: 
                 outf.write(decshare[:filesize])
                 return