Skip to content

Commit 997a6e0

Browse files
committed
fix: encode multifile hash as utf8
1 parent 619263f commit 997a6e0

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎pins/tests/test_versions.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ def test_version_from_files(bytes_):
5151

5252
assert v.hash == digest
5353
assert v.created == EXAMPLE_DATE
54+
55+
56+
def test_version_from_files_multiple():
57+
files = [BytesIO(b"123"), BytesIO(b"456")]
58+
v = Version.from_files(files, EXAMPLE_DATE)
59+
60+
combined = xxhash.xxh64(b"123").hexdigest() + xxhash.xxh64(b"456").hexdigest()
61+
assert v.hash == xxhash.xxh64(combined.encode("utf-8")).hexdigest()
62+
assert v.created == EXAMPLE_DATE

‎pins/versions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def from_files(
109109
combined_hashes = "".join(hashes)
110110

111111
# Create an xxh64 hash of the combined string
112-
hashes = [xxh64(combined_hashes).hexdigest()]
112+
hashes = [xxh64(combined_hashes.encode("utf-8")).hexdigest()]
113113

114114
return cls(created, hashes[0])
115115

0 commit comments

Comments
 (0)