From 3bc819e56742cec3b60ec209e22004ae7ee783b3 Mon Sep 17 00:00:00 2001 From: derrod Date: Mon, 10 Jan 2022 17:14:30 +0100 Subject: [PATCH] [core] Check install directory for write access Fixes #395 --- legendary/core.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/legendary/core.py b/legendary/core.py index e340127..6cc1688 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -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: