def get_sha1(self): if self._sha1 is None: if self.relative_offset == 0 and self.length == self.upload_source.get_content_length( ): # this is part is equal to whole upload source - so we use `get_content_sha1()` # and if sha1 is already given, we skip computing it again self._sha1 = self.upload_source.get_content_sha1() else: with self._get_stream() as stream: self._sha1, _ = hex_sha1_of_unlimited_stream(stream) return self._sha1
def get_subpart_id(self): with self._get_stream() as stream: sha1, _ = hex_sha1_of_unlimited_stream(stream) return sha1
def _set_content_length_and_sha1(self): sha1, content_length = hex_sha1_of_unlimited_stream(self.open()) self._content_length = content_length self._content_sha1 = sha1
def get_sha1(self): if self._sha1 is None and self.is_hashable(): with self._get_stream() as stream: self._sha1, _ = hex_sha1_of_unlimited_stream(stream) return self._sha1