Create cache dir if not exists

This commit is contained in:
Luke Van Seters 2021-09-13 18:34:40 -04:00
parent e6aa8a2aed
commit 54d60bc674

View File

@ -70,6 +70,8 @@ def get_transaction_hashes(calls: List[Trace]) -> List[str]:
def cache_block(cache_path: Path, block: Block): def cache_block(cache_path: Path, block: Block):
write_mode = "w" if cache_path.is_file() else "x" write_mode = "w" if cache_path.is_file() else "x"
cache_path.parent.mkdir(parents=True, exist_ok=True)
with open(cache_path, mode=write_mode) as cache_file: with open(cache_path, mode=write_mode) as cache_file:
cache_file.write(block.json()) cache_file.write(block.json())