diff -rN -u old-1.8.2/src/allmydata/immutable/encode.py new-1.8.2/src/allmydata/immutable/encode.py
old
|
new
|
|
105 | 105 | def _got_size(size): |
106 | 106 | self.log(format="file size: %(size)d", size=size) |
107 | 107 | self.file_size = size |
| 108 | precondition(isinstance(self.file_size, (int, long)), self.file_size) |
108 | 109 | d.addCallback(_got_size) |
109 | 110 | d.addCallback(lambda res: eu.get_all_encoding_parameters()) |
110 | 111 | d.addCallback(self._got_all_encoding_parameters) |
… |
… |
|
118 | 119 | def _got_all_encoding_parameters(self, params): |
119 | 120 | assert not self._codec |
120 | 121 | k, happy, n, segsize = params |
| 122 | precondition(isinstance(segsize, (int, long)), segsize) |
121 | 123 | self.required_shares = k |
122 | 124 | self.servers_of_happiness = happy |
123 | 125 | self.num_shares = n |
… |
… |
|
129 | 131 | |
130 | 132 | self.num_segments = mathutil.div_ceil(self.file_size, |
131 | 133 | self.segment_size) |
| 134 | precondition(isinstance(self.num_segments, (int, long)), self.num_segments) |
132 | 135 | |
133 | 136 | self._codec = CRSEncoder() |
134 | 137 | self._codec.set_params(self.segment_size, |
diff -rN -u old-1.8.2/src/allmydata/immutable/upload.py new-1.8.2/src/allmydata/immutable/upload.py
old
|
new
|
|
608 | 608 | d = self.original.get_all_encoding_parameters() |
609 | 609 | def _got(encoding_parameters): |
610 | 610 | (k, happy, n, segsize) = encoding_parameters |
| 611 | precondition(isinstance(segsize, (int, long)), segsize) |
611 | 612 | self._segment_size = segsize # used by segment hashers |
612 | 613 | self._encoding_parameters = encoding_parameters |
613 | 614 | self.log("my encoding parameters: %s" % (encoding_parameters,), |
… |
… |
|
915 | 916 | share_size = encoder.get_param("share_size") |
916 | 917 | block_size = encoder.get_param("block_size") |
917 | 918 | num_segments = encoder.get_param("num_segments") |
| 919 | precondition(isinstance(num_segments, (int, long)), num_segments) |
918 | 920 | k,desired,n = encoder.get_param("share_counts") |
919 | 921 | |
920 | 922 | self._peer_selection_started = time.time() |
… |
… |
|
1270 | 1272 | if self._all_encoding_parameters: |
1271 | 1273 | return defer.succeed(self._all_encoding_parameters) |
1272 | 1274 | |
| 1275 | precondition(self.max_segment_size is None or isinstance(self.max_segment_size, (int, long)), self.max_segment_size) |
| 1276 | precondition(isinstance(self.default_max_segment_size, (int, long)), self.default_max_segment_size) |
1273 | 1277 | max_segsize = self.max_segment_size or self.default_max_segment_size |
1274 | 1278 | k = self.encoding_param_k or self.default_encoding_param_k |
1275 | 1279 | happy = self.encoding_param_happy or self.default_encoding_param_happy |
… |
… |
|
1277 | 1281 | |
1278 | 1282 | d = self.get_size() |
1279 | 1283 | def _got_size(file_size): |
| 1284 | precondition(isinstance(file_size, (int, long)), file_size) |
1280 | 1285 | # for small files, shrink the segment size to avoid wasting space |
1281 | 1286 | segsize = min(max_segsize, file_size) |
| 1287 | precondition(isinstance(segsize, (int, long)), segsize) |
1282 | 1288 | # this must be a multiple of 'required_shares'==k |
1283 | 1289 | segsize = mathutil.next_multiple(segsize, k) |
| 1290 | precondition(isinstance(segsize, (int, long)), segsize) |
1284 | 1291 | encoding_parameters = (k, happy, n, segsize) |
1285 | 1292 | self._all_encoding_parameters = encoding_parameters |
1286 | 1293 | return encoding_parameters |