Skip to content

Commit

Permalink
0.9.8.6
Browse files Browse the repository at this point in the history
#####
1. 修复路径问题

#####
  • Loading branch information
Xingsandesu committed Jan 19, 2024
1 parent 40602eb commit bfe2f29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
'get_docker_shell_command': 'curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh'
}

# 如果目录不存在,创建它
if not os.path.exists(os.path.dirname(config_path)):
os.makedirs(os.path.dirname(config_path))

# 如果存在,尝试打开文件并读取值
if os.path.exists(config_path):
try:
Expand Down
8 changes: 7 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ class Config:
SECRET_KEY = token_hex(16)
SQLALCHEMY_TRACK_MODIFICATIONS = False
prefix = 'sqlite:///'
SQLALCHEMY_DATABASE_URI = prefix + os.path.join(os.path.dirname(argv[0]), 'work', 'data.db')
db_dir = os.path.join(os.path.dirname(argv[0]), 'work')

# 确保数据库目录存在
if not os.path.exists(db_dir):
os.makedirs(db_dir)

SQLALCHEMY_DATABASE_URI = prefix + os.path.join(db_dir, 'data.db')


######################### 数据库相关Class结束 #########################
Expand Down

0 comments on commit bfe2f29

Please sign in to comment.