mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[core] Honor existing installation directory
This prevents an issue where changing the base path later on would cause an update to be written to the wrong directory (or cause crashes).
This commit is contained in:
parent
532e1df237
commit
e88a369feb
|
@ -552,23 +552,28 @@ class LegendaryCore:
|
||||||
self.lgd.save_manifest(game.app_name, new_manifest_data,
|
self.lgd.save_manifest(game.app_name, new_manifest_data,
|
||||||
version=new_manifest.meta.build_version)
|
version=new_manifest.meta.build_version)
|
||||||
|
|
||||||
if not game_folder:
|
# reuse existing installation's directory
|
||||||
if game.is_dlc:
|
if igame := self.get_installed_game(base_game.app_name if base_game else game.app_name):
|
||||||
game_folder = base_game.metadata.get('customAttributes', {}).\
|
install_path = igame.install_path
|
||||||
get('FolderName', {}).get('value', base_game.app_name)
|
else:
|
||||||
else:
|
if not game_folder:
|
||||||
game_folder = game.metadata.get('customAttributes', {}).\
|
if game.is_dlc:
|
||||||
get('FolderName', {}).get('value', game.app_name)
|
game_folder = base_game.metadata.get('customAttributes', {}).\
|
||||||
|
get('FolderName', {}).get('value', base_game.app_name)
|
||||||
|
else:
|
||||||
|
game_folder = game.metadata.get('customAttributes', {}).\
|
||||||
|
get('FolderName', {}).get('value', game.app_name)
|
||||||
|
|
||||||
if not base_path:
|
if not base_path:
|
||||||
base_path = self.get_default_install_dir()
|
base_path = self.get_default_install_dir()
|
||||||
|
|
||||||
# make sure base directory actually exists (but do not create game dir)
|
# make sure base directory actually exists (but do not create game dir)
|
||||||
if not os.path.exists(base_path):
|
if not os.path.exists(base_path):
|
||||||
self.log.info(f'"{base_path}" does not exist, creating...')
|
self.log.info(f'"{base_path}" does not exist, creating...')
|
||||||
os.makedirs(base_path)
|
os.makedirs(base_path)
|
||||||
|
|
||||||
|
install_path = os.path.join(base_path, game_folder)
|
||||||
|
|
||||||
install_path = os.path.join(base_path, game_folder)
|
|
||||||
self.log.info(f'Install path: {install_path}')
|
self.log.info(f'Install path: {install_path}')
|
||||||
|
|
||||||
if not force:
|
if not force:
|
||||||
|
|
Loading…
Reference in a new issue