Move config to shared data directory
This commit is contained in:
@@ -6,3 +6,5 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
environment:
|
environment:
|
||||||
LIBOPUS: "/usr/lib/libopus.so.0"
|
LIBOPUS: "/usr/lib/libopus.so.0"
|
||||||
|
volumes:
|
||||||
|
- "./data:/usr/src/app/data"
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
|
import os
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
CONFIG = 'config.json'
|
CONFIG = 'data/config.json'
|
||||||
config: dict = {
|
config: dict = {
|
||||||
'inf19x-insiders-enable': False,
|
'inf19x-insiders-enable': False,
|
||||||
'loeh-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:
|
def config_load() -> dict:
|
||||||
try:
|
try:
|
||||||
|
_make_dirs()
|
||||||
config_file = open(CONFIG, 'r')
|
config_file = open(CONFIG, 'r')
|
||||||
config.update(json.load(config_file))
|
config.update(json.load(config_file))
|
||||||
except (json.JSONDecodeError, FileNotFoundError):
|
except (json.JSONDecodeError, FileNotFoundError):
|
||||||
@@ -48,6 +54,7 @@ def config_load() -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def config_save():
|
def config_save():
|
||||||
|
_make_dirs()
|
||||||
with open(CONFIG, 'w') as config_file:
|
with open(CONFIG, 'w') as config_file:
|
||||||
json.dump(config, config_file)
|
json.dump(config, config_file)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user