fix(backend): get_settings fills missing DEFAULTS keys for stale config documents
This commit is contained in:
parent
9eca0fbd52
commit
3f7f6fb621
1 changed files with 6 additions and 0 deletions
|
|
@ -53,6 +53,12 @@ async def get_settings() -> dict:
|
|||
if not doc:
|
||||
await db.app_settings.insert_one(DEFAULTS.copy())
|
||||
doc = DEFAULTS.copy()
|
||||
else:
|
||||
# Fill in any keys added to DEFAULTS since the document was first created
|
||||
missing = {k: v for k, v in DEFAULTS.items() if k not in doc}
|
||||
if missing:
|
||||
await db.app_settings.update_one({"_id": "config"}, {"$set": missing})
|
||||
doc.update(missing)
|
||||
|
||||
_cache = doc
|
||||
_cache_ts = time.monotonic()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue