[cli] Make it possible to uninstall DLC

This commit is contained in:
derrod 2021-10-10 17:08:05 +02:00
parent 205f960ed4
commit 6d3a8af70b

View file

@ -958,9 +958,6 @@ class LegendaryCLI:
if not igame:
logger.error(f'Game {args.app_name} not installed, cannot uninstall!')
exit(0)
if igame.is_dlc:
logger.error('Uninstalling DLC is not supported.')
exit(1)
if not args.yes:
if not get_boolean_choice(f'Do you wish to uninstall "{igame.title}"?', default=False):
@ -968,6 +965,7 @@ class LegendaryCLI:
exit(0)
try:
if not igame.is_dlc:
# Remove DLC first so directory is empty when game uninstall runs
dlcs = self.core.get_dlc_for_game(igame.app_name)
for dlc in dlcs:
@ -976,7 +974,8 @@ class LegendaryCLI:
self.core.uninstall_game(idlc, delete_files=not args.keep_files)
logger.info(f'Removing "{igame.title}" from "{igame.install_path}"...')
self.core.uninstall_game(igame, delete_files=not args.keep_files, delete_root_directory=True)
self.core.uninstall_game(igame, delete_files=not args.keep_files,
delete_root_directory=not igame.is_dlc)
logger.info('Game has been uninstalled.')
except Exception as e:
logger.warning(f'Removing game failed: {e!r}, please remove {igame.install_path} manually.')