diff --git a/pydra/utils/hash.py b/pydra/utils/hash.py index e2090d0102..96c2c1b426 100644 --- a/pydra/utils/hash.py +++ b/pydra/utils/hash.py @@ -60,7 +60,8 @@ def location_converter(path: ty.Union[Path, str, None]) -> Path: if path is None: path = PersistentCache.location_default() path = Path(path) - path.mkdir(parents=True, exist_ok=True) + if not path.exists(): + path.mkdir(parents=True) return path diff --git a/pydra/utils/tests/test_hash.py b/pydra/utils/tests/test_hash.py index 7ed93c6edb..91333690a4 100644 --- a/pydra/utils/tests/test_hash.py +++ b/pydra/utils/tests/test_hash.py @@ -335,11 +335,9 @@ def test_persistent_hash_cache(cache_path, text_file): assert hash_object(text_file, persistent_cache=cache_path) == modified_hash # Test that changes to the text file result in new hash + time.sleep(2) # Need to ensure that the mtimes will be different text_file.fspath.write_text("bar") - # Ensure that the mtime will be incremented by mocking time.time - with mock.patch("time.time") as t: - t.return_value = time.time() + 10 - assert hash_object(text_file, persistent_cache=cache_path) != modified_hash + assert hash_object(text_file, persistent_cache=cache_path) != modified_hash assert len(list(cache_path.iterdir())) == 2