Skip to content

Commit

Permalink
[cli] Write tags to config after successful verification
Browse files Browse the repository at this point in the history
If a game has a `__required` SDL which is an empty string will fail verification
because the check for building the list of hashes will fail, implying that the
whole game including all the SDLs will be validated.

At the same time, if we are importing a game using a config file that doesn't
specify the `install_tags` for such a game, the install tags won't be saved
due to calling an early `exit(0)`.

These two issues combined can cause a verification, repair, verification loop.
This commit addresses both of those issues.

Related convertation on Discord:
https://discord.com/channels/695233346627698689/695234626582609940/1084939380713594924
  • Loading branch information
loathingKernel authored and derrod committed Jul 28, 2023
1 parent b759d9d commit 20b121b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion legendary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,10 @@ def install_game(self, args):
self.core.uninstall_tag(old_igame)
self.core.install_game(old_igame)

if old_igame.install_tags:
self.core.lgd.config.set(game.app_name, 'install_tags', ','.join(old_igame.install_tags))
self.core.lgd.save_config()

# check if the version changed, this can happen for DLC that gets a version bump with no actual file changes
if old_igame and old_igame.version != igame.version:
old_igame.version = igame.version
Expand Down Expand Up @@ -1225,7 +1229,7 @@ def verify_game(self, args, print_command=True, repair_mode=False, repair_online
key=lambda a: a.filename.lower())

# build list of hashes
if config_tags := self.core.lgd.config.get(args.app_name, 'install_tags', fallback=None):
if config_tags := self.core.lgd.config.get(args.app_name, 'install_tags', fallback=None) is not None:
install_tags = set(i.strip() for i in config_tags.split(','))
file_list = [
(f.filename, f.sha_hash.hex())
Expand Down

0 comments on commit 20b121b

Please sign in to comment.