Skip to content

Commit d971b02

Browse files
committed
add permission check for cache directory creation
1 parent 7d97b8e commit d971b02

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pydelmod/schismstudy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ def __init__(
133133
self.base_dir, pathlib.Path(output_dir)
134134
)
135135
try:
136+
# check permissions to create cache in base_dir
137+
test_cache_path = self.base_dir / ".cache-schismstudy"
138+
test_cache_path.mkdir(parents=True, exist_ok=True)
139+
if not os.access(test_cache_path, os.W_OK):
140+
raise PermissionError("No write access to cache directory.")
136141
self.cache = diskcache.Cache(self.base_dir / ".cache-schismstudy")
137142
except:
138143
logger.warning("Could not create cache. Using temporary cache.")

0 commit comments

Comments
 (0)