[core] Check install directory for write access

Fixes #395
This commit is contained in:
derrod 2022-01-10 17:14:30 +01:00
parent 742d3a3b05
commit 3bc819e567

View file

@ -1333,6 +1333,13 @@ class LegendaryCore:
install_path = os.path.normpath(os.path.join(base_path, game_folder))
# check for write access on the install path or its parent directory if it doesn't exist yet
base_path = os.path.dirname(install_path)
if os.path.exists(install_path) and not os.access(install_path, os.W_OK):
raise PermissionError(f'No write access to "{install_path}"')
elif not os.access(base_path, os.W_OK):
raise PermissionError(f'No write access to "{base_path}"')
self.log.info(f'Install path: {install_path}')
if repair: