Skip to content

Commit

Permalink
feat: separate attachment checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Oct 9, 2023
1 parent 7d2fdc6 commit 3b52ee4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions polarion_rest_api_client/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ def calculate_checksum(self) -> str:
del data["checksum"]
del data["id"]

for at in data["attachments"]:
del at["id"]
attachments = data.pop("attachments")

data = dict(sorted(data.items()))

converted = json.dumps(data).encode("utf8")
self._checksum = hashlib.sha256(converted).hexdigest()
converted_attachments = json.dumps(attachments).encode("utf8")
self._checksum = (
hashlib.sha256(converted).hexdigest()
+ " "
+ hashlib.sha256(converted_attachments).hexdigest()
)
return self._checksum

def get_current_checksum(self) -> str | None:
Expand Down

0 comments on commit 3b52ee4

Please sign in to comment.