未验证 提交 083a8aa2 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

fix config.json bug on windows (#544)

上级 f71593d2
......@@ -46,7 +46,8 @@ class HubServer(object):
config_file_path = os.path.join(CONF_HOME, 'config.json')
if not os.path.exists(CONF_HOME):
utils.mkdir(CONF_HOME)
if not os.path.exists(config_file_path):
if not os.path.exists(config_file_path) or 0 == os.path.getsize(
config_file_path):
with open(config_file_path, 'w+') as fp:
lock.flock(fp, lock.LOCK_EX)
fp.write(json.dumps(default_server_config))
......
......@@ -62,7 +62,8 @@ class Logger(object):
self.logger.setLevel(logging.DEBUG)
self.logger.propagate = False
if os.path.exists(os.path.join(CONF_HOME, "config.json")):
config_path = os.path.join(CONF_HOME, "config.json")
if os.path.exists(config_path) and 0 < os.path.getsize(config_path):
with open(os.path.join(CONF_HOME, "config.json"), "r") as fp:
level = json.load(fp).get("log_level", "DEBUG")
self.logLevel = level
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册