Skip to content

Commit

Permalink
Merge pull request #60 from shininome/shino_aio
Browse files Browse the repository at this point in the history
fix config error
  • Loading branch information
shininome authored Oct 25, 2024
2 parents 714832d + 17b6e15 commit b4d456d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions backend/src/module/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ async def get_config():
)
async def update_config(config: Config):
try:
settings.save(config_dict=config.model_dump())
settings.save(config_dict=config.dict())
settings.load()
# update_rss()
logger.info("Config updated")
return JSONResponse(
status_code=200,
content={"msg_en": "Update config successfully.", "msg_zh": "更新配置成功。"},
content={
"msg_en": "Update config successfully.",
"msg_zh": "更新配置成功。",
},
)
except Exception as e:
logger.warning(e)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/module/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def load(self):

def save(self, config_dict: dict | None = None):
if not config_dict:
config_dict = self.model_dump()
config_dict = self.dict()
with open(CONFIG_PATH, "w", encoding="utf-8") as f:
json.dump(config_dict, f, indent=4, ensure_ascii=False)

Expand All @@ -160,7 +160,7 @@ def init(self):
self.save()

def __load_from_env(self):
config_dict = self.model_dump()
config_dict = self.dict()
for key, section in ENV_TO_ATTR.items():
for env, attr in section.items():
if env in os.environ:
Expand Down

0 comments on commit b4d456d

Please sign in to comment.