Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cache directory path Windows friendly #71

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ def _dirhash(self, directory, hash, ignore_hidden=False,
"""Returns hash of directory's file contents"""
assert Path(directory).is_dir()
try:
dir_iter = sorted(Path(directory).iterdir(), key=lambda p: str(p).lower())
dir_iter = sorted(Path(directory).iterdir(),
key=lambda p: str(p).lower())
except FileNotFoundError:
return hash
for path in dir_iter:
Expand Down Expand Up @@ -433,7 +434,7 @@ def generate_cache_hash(self, method_kwargs):
params["tfdir"] = self._dirhash(self.tfdir, sha1(), ignore_hidden=True,
exclude_directories=[".terraform"],
excluded_extensions=['.backup', '.tfstate'
]).hexdigest()
]).hexdigest()

return sha1(
json.dumps(params, sort_keys=True,
Expand All @@ -458,7 +459,7 @@ def cache(self, **kwargs):
return func(self, **kwargs)

cache_dir = self.cache_dir / \
Path(self.tfdir.strip("/")) / Path(func.__name__)
Path(sha1(self.tfdir.encode("cp037")).hexdigest()) / Path(func.__name__)
cache_dir.mkdir(parents=True, exist_ok=True)

hash_filename = self.generate_cache_hash(kwargs)
Expand Down