Move config to shared data directory

This commit is contained in:
2021-01-19 11:15:30 +01:00
parent e82acb1b13
commit 56ff31c131
2 changed files with 10 additions and 1 deletions

View File

@@ -6,3 +6,5 @@ services:
tty: true
environment:
LIBOPUS: "/usr/lib/libopus.so.0"
volumes:
- "./data:/usr/src/app/data"

View File

@@ -1,7 +1,8 @@
import json
import os
from typing import Optional
CONFIG = 'config.json'
CONFIG = 'data/config.json'
config: dict = {
'inf19x-insiders-enable': False,
'loeh-enable': False,
@@ -38,8 +39,13 @@ config_meta: dict = {
}
def _make_dirs():
os.makedirs(os.path.dirname(CONFIG), exist_ok=True)
def config_load() -> dict:
try:
_make_dirs()
config_file = open(CONFIG, 'r')
config.update(json.load(config_file))
except (json.JSONDecodeError, FileNotFoundError):
@@ -48,6 +54,7 @@ def config_load() -> dict:
def config_save():
_make_dirs()
with open(CONFIG, 'w') as config_file:
json.dump(config, config_file)