Only try to chmod runtime dir if actually needed

This commit is contained in:
Kovid Goyal
2022-03-13 13:45:03 +05:30
parent db00adaf69
commit f3088c5646
2 changed files with 5 additions and 2 deletions

View File

@@ -151,7 +151,9 @@ def runtime_dir() -> str:
if not os.path.isdir(candidate) or not os.access(candidate, os.X_OK | os.W_OK | os.R_OK):
candidate = os.path.join(cache_dir(), 'run')
os.makedirs(candidate, exist_ok=True)
os.chmod(candidate, 0o700)
import stat
if stat.S_IMODE(os.stat(candidate).st_mode) != 0o700:
os.chmod(candidate, 0o700)
return candidate