Skip to content

Commit

Permalink
build: Use dirhash dependency for dir hashes (#110)
Browse files Browse the repository at this point in the history
* Use dirhash library over checksumdir, as dirhash is maintained and
  checksumdir is not.
   - c.f. https://github.com/to-mc/checksumdir
   - state_hash states it returns the SHA1 hash, so use sha1 for the
     algorithm.
* Apply isort.
  • Loading branch information
matthewfeickert authored Jun 17, 2024
1 parent 29a6c6e commit e9e61bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packtivity/statecontexts/posixfs_context.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import hashlib
import os
import shutil
import json
import logging
import checksumdir
import os
import shutil

import six
from dirhash import dirhash

import packtivity.utils as utils

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -116,12 +118,12 @@ def state_hash(self):
"""
# hash the upstream / input state
dep_checksums = [
checksumdir.dirhash(d) for d in self.readonly if os.path.isdir(d)
dirhash(d, "sha1") for d in self.readonly if os.path.isdir(d)
]

# hash out writing state
state_checksums = [
checksumdir.dirhash(d) for d in self.readwrite if os.path.isdir(d)
dirhash(d, "sha1") for d in self.readwrite if os.path.isdir(d)
]
return hashlib.sha1(
json.dumps([dep_checksums, state_checksums]).encode("utf-8")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"jq>=1.0.0",
"yadage-schemas",
"mock",
"checksumdir",
"dirhash>=0.4.0",
]

if not "READTHEDOCS" in os.environ:
Expand Down

0 comments on commit e9e61bd

Please sign in to comment.