From c7b7978b8d8f6c1e4152d29e8cc1ff03e9a0dc81 Mon Sep 17 00:00:00 2001 From: "dengsheng.chen" Date: Thu, 24 Dec 2020 18:00:36 +0800 Subject: [PATCH] Fxi a crash issue while using cloudreve as a third-party library, there is no database. --- models/setting.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/setting.go b/models/setting.go index f8157cf..d1c1096 100644 --- a/models/setting.go +++ b/models/setting.go @@ -78,7 +78,12 @@ func GetSiteURL() *url.URL { } // GetIntSetting 获取整形设置值,如果转换失败则返回默认值defaultVal -func GetIntSetting(key string, defaultVal int) int { +func GetIntSetting(key string, defaultVal int) (ret int) { + defer func() { + if v := recover(); v != nil { + ret = defaultVal + } + }() res, err := strconv.Atoi(GetSettingByName(key)) if err != nil { return defaultVal