diff --git a/legendary/cli.py b/legendary/cli.py index c884c51..c6faa74 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -598,8 +598,6 @@ class LegendaryCLI: config_tags = self.core.lgd.config.get(game.app_name, 'install_tags', fallback=None) if not self.core.is_installed(game.app_name) or config_tags is None or args.reset_sdl: args.install_tag = sdl_prompt(sdl_name, game.app_title) - if game.app_name not in self.core.lgd.config: - self.core.lgd.config[game.app_name] = dict() self.core.lgd.config.set(game.app_name, 'install_tags', ','.join(args.install_tag)) else: args.install_tag = config_tags.split(',') diff --git a/legendary/core.py b/legendary/core.py index d259790..9128f09 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -1152,8 +1152,6 @@ class LegendaryCore: # transfer install tag choices to config if lgd_igame.install_tags: - if app_name not in self.lgd.config: - self.lgd.config[app_name] = dict() self.lgd.config.set(app_name, 'install_tags', ','.join(lgd_igame.install_tags)) # mark game as installed diff --git a/legendary/utils/config.py b/legendary/utils/config.py index 5738a19..1036aec 100644 --- a/legendary/utils/config.py +++ b/legendary/utils/config.py @@ -22,12 +22,16 @@ class LGDConf(configparser.ConfigParser): super().write(*args, **kwargs) self.modtime = int(time.time()) - def set(self, *args, **kwargs): + def set(self, section, option, value=None): if self.read_only: return + # ensure config section exists + if not self.has_section(section): + self.add_section(section) + self.modified = True - super().set(*args, **kwargs) + super().set(section, option, value) def remove_option(self, section, option): if self.read_only: