Skip to content

Instantly share code, notes, and snippets.

@clayg
Created March 5, 2015 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/baced99e9463838026df to your computer and use it in GitHub Desktop.
Save clayg/baced99e9463838026df to your computer and use it in GitHub Desktop.
diff --git a/swift/common/storage_policy.py b/swift/common/storage_policy.py
index a0c2cd1..c3ae546 100644
--- a/swift/common/storage_policy.py
+++ b/swift/common/storage_policy.py
@@ -420,13 +420,14 @@ class ECStoragePolicy(StoragePolicy):
NB: a fragment archive is a sequence of 0 or more max-length
fragments followed by one possibly-shorter fragment.
"""
- if self._fragment_header_len is None:
- # this header is a fixed size, so it's perfectly okay to learn
- # it by encoding some dummy data
- self._fragment_header_len = len(self.pyeclib_driver.encode("")[0])
-
- return (
- self.ec_segment_size // self._ec_ndata + self._fragment_header_len)
+ # it is not clear why this is the correct call signature to get the
+ # answer we need. It calls for (data_len, segment_size) but on a
+ # ranged GET we don't know the ec-content-length header before we need
+ # to compute where in the object we should request to align with the
+ # fragment size. So we tell pyeclib a lie - and it gives us the
+ # number we want - but only sam and kevin might know why this "works".
+ return self.pyeclib_driver.get_segment_info(
+ self.ec_segment_size, self.ec_segment_size)['fragment_size']
def decode_fragments(self, frags):
return self.pyeclib_driver.decode(frags)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment