diff --git a/katrain/config.json b/katrain/config.json index d5e3957..7d0f667 100644 --- a/katrain/config.json +++ b/katrain/config.json @@ -16,7 +16,7 @@ "anim_pv_time": 0.5, "debug_level": 0, "lang": "en", - "version": "1.2.0" + "version": "1.2.2" }, "timer": { "byo_length": 30, diff --git a/katrain/core/base_katrain.py b/katrain/core/base_katrain.py index a3e6e94..f26e4bd 100644 --- a/katrain/core/base_katrain.py +++ b/katrain/core/base_katrain.py @@ -85,13 +85,16 @@ class KaTrainBase: config_file = user_config_file self.log(f"Copied package config to local file {config_file}", OUTPUT_INFO) else: # user file exists - version = JsonStore(user_config_file, indent=4).get("general")["version"] + try: + version = JsonStore(user_config_file).get("general")["version"] + except Exception: # broken file etc + version = "0.0.0" if version < CONFIG_MIN_VERSION: backup = user_config_file + f".{version}.backup" shutil.copyfile(user_config_file, backup) shutil.copyfile(package_config_file, user_config_file) self.log( - f"Copied package config file to {user_config_file} as user file is outdated (<{CONFIG_MIN_VERSION}). Old version stored as {backup}", + f"Copied package config file to {user_config_file} as user file is outdated or broken ({version}<{CONFIG_MIN_VERSION}). Old version stored as {backup}", OUTPUT_INFO, ) config_file = user_config_file