From 814fbb73f312bae289b11dfc0415eb491a04907b Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 2 Jun 2024 18:14:36 -0700 Subject: [PATCH] feat: RESET_CONFIG_ON_START --- backend/config.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/config.py b/backend/config.py index 32820072f..286a80b92 100644 --- a/backend/config.py +++ b/backend/config.py @@ -180,6 +180,17 @@ WEBUI_BUILD_HASH = os.environ.get("WEBUI_BUILD_HASH", "dev-build") DATA_DIR = Path(os.getenv("DATA_DIR", BACKEND_DIR / "data")).resolve() FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", BASE_DIR / "build")).resolve() +RESET_CONFIG_ON_START = ( + os.environ.get("RESET_CONFIG_ON_START", "False").lower() == "true" +) +if RESET_CONFIG_ON_START: + try: + os.remove(f"{DATA_DIR}/config.json") + with open(f"{DATA_DIR}/config.json", "w") as f: + f.write("{}") + except: + pass + try: CONFIG_DATA = json.loads((DATA_DIR / "config.json").read_text()) except: