mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 01:12:33 -05:00
Fix issues with loading config.json when it doesn't exist (#5416)
* catch and handle FileNotFoundError when using --no-instance when config.json does not already exist * move load_existing_config to data_manager.py * use load_existing_config in create_temp_config * Fix import in redbot-launcher Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -37,16 +37,7 @@ except PermissionError:
|
||||
sys.exit(1)
|
||||
config_file = config_dir / "config.json"
|
||||
|
||||
|
||||
def load_existing_config():
|
||||
if not config_file.exists():
|
||||
return {}
|
||||
|
||||
with config_file.open(encoding="utf-8") as fs:
|
||||
return json.load(fs)
|
||||
|
||||
|
||||
instance_data = load_existing_config()
|
||||
instance_data = data_manager.load_existing_config()
|
||||
if instance_data is None:
|
||||
instance_list = []
|
||||
else:
|
||||
@@ -54,7 +45,7 @@ else:
|
||||
|
||||
|
||||
def save_config(name, data, remove=False):
|
||||
_config = load_existing_config()
|
||||
_config = data_manager.load_existing_config()
|
||||
if remove and name in _config:
|
||||
_config.pop(name)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user