Force move the old config.json to .bak, even if one exists. This is required for recovering from inconsistent states

This commit is contained in:
cmdr2 2023-06-30 09:44:23 +05:30
parent fdc6a4d94b
commit 81a24249e6

View File

@ -1,6 +1,7 @@
import json import json
import logging import logging
import os import os
import shutil
import socket import socket
import sys import sys
import traceback import traceback
@ -133,7 +134,7 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
config = json.load(f) config = json.load(f)
# Save config in new format # Save config in new format
setConfig(config) setConfig(config)
os.rename(config_json_path, config_json_path + ".bak") shutil.move(config_json_path, config_json_path + ".bak")
log.info("Saved old config.json as config.json.bak") log.info("Saved old config.json as config.json.bak")
return getConfig(default_val) return getConfig(default_val)
except Exception as e: except Exception as e: