From: Brian Warner Date: Tue, 17 Apr 2007 20:39:35 +0000 (-0700) Subject: download.py: don't truncate tail segments that are the same size as all the others X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~84 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/schema.xhtml?a=commitdiff_plain;h=c3268ca394713daffada1b2321d00002f27938b9;p=tahoe-lafs%2Ftahoe-lafs.git download.py: don't truncate tail segments that are the same size as all the others --- diff --git a/src/allmydata/download.py b/src/allmydata/download.py index 1861d75d..e668dde8 100644 --- a/src/allmydata/download.py +++ b/src/allmydata/download.py @@ -323,7 +323,10 @@ class FileDownloader: def _done(res): # trim off any padding added by the upload side data = ''.join(res) - tail_size = self._size % self._segment_size + # we never send empty segments. If the data was an exact multiple + # of the segment size, the last segment will be full. + pad_size = mathutil.pad_size(self._size, self._segment_size) + tail_size = self._segment_size - pad_size self._output.write(data[:tail_size]) d.addCallback(_done) return d