storage.py: assert that immutable share size will fit in the 4-byte v1 container (see #346). The struct module in py2.4 raises an error on overflow, but py2.5 merely emits a warning

This commit is contained in:
Brian Warner 2008-10-20 10:22:08 -07:00
parent c08b0eb1ea
commit 0832334c0d

View File

@ -236,6 +236,7 @@ class BucketWriter(Referenceable):
fileutil.make_dirs(os.path.dirname(incominghome))
# Also construct the metadata.
f = open(incominghome, 'wb')
precondition(size < 2**32) # v1 container format: 4-byte size field
f.write(struct.pack(">LLL", 1, size, 0))
f.close()
self._sharefile = ShareFile(incominghome)