diff options
author | Alistair Coles <alistairncoles@gmail.com> | 2023-04-26 11:20:42 +0100 |
---|---|---|
committer | Alistair Coles <alistairncoles@gmail.com> | 2023-04-26 11:33:41 +0100 |
commit | 50c4ea032d5d713583b6247f054c82f5cf540661 (patch) | |
tree | 0c2743f7b6df260ddb66a4b3d34e078d7bc82bd6 /swift | |
parent | 0f95870c51c696b076b3c9b266e1d7cde52a30d4 (diff) | |
download | swift-50c4ea032d5d713583b6247f054c82f5cf540661.tar.gz |
ECFragGetter: assume policy.fragment_size is non-zero
Simplify ECFragGetter by removing code that guards against the policy
fragment_size being None or zero.
Policy fragment_size must be > 0: the fragment_size is based on the
ec_segment_size, which is verified as > 0 when constructing an EC
policy. This is asserted by test_parse_storage_policies in
test.unit.common.test_storage_policy.TestStoragePolicies.
Also, rename client_chunk_size to fragment_size for clarity.
Change-Id: Ie1efaab3bd0510275d534b5c023cb73c98bec90d
Diffstat (limited to 'swift')
-rw-r--r-- | swift/proxy/controllers/obj.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index fa9169e47..a0e29e65a 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -2497,7 +2497,7 @@ class ECFragGetter(object): self.backend_headers = backend_headers self.header_provider = header_provider self.req_query_string = req.query_string - self.client_chunk_size = policy.fragment_size + self.fragment_size = policy.fragment_size self.skip_bytes = 0 self.bytes_used_from_backend = 0 self.source = self.node = None @@ -2578,8 +2578,8 @@ class ECFragGetter(object): def learn_size_from_content_range(self, start, end, length): """ - If client_chunk_size is set, makes sure we yield things starting on - chunk boundaries based on the Content-Range header in the response. + Make sure we yield things starting on fragment boundaries based on the + Content-Range header in the response. Sets our Range header's first byterange to the value learned from the Content-Range header in the response; if we were given a @@ -2593,8 +2593,7 @@ class ECFragGetter(object): if length == 0: return - if self.client_chunk_size: - self.skip_bytes = bytes_to_skip(self.client_chunk_size, start) + self.skip_bytes = bytes_to_skip(self.fragment_size, start) if 'Range' in self.backend_headers: try: @@ -2725,10 +2724,9 @@ class ECFragGetter(object): self.bytes_used_from_backend += len(buf) buf = b'' - client_chunk_size = self.client_chunk_size or len(buf) - while buf and (len(buf) >= client_chunk_size or not chunk): - client_chunk = buf[:client_chunk_size] - buf = buf[client_chunk_size:] + while buf and (len(buf) >= self.fragment_size or not chunk): + client_chunk = buf[:self.fragment_size] + buf = buf[self.fragment_size:] with WatchdogTimeout(self.app.watchdog, self.app.client_timeout, ChunkWriteTimeout): |