From 883898f053497104baa8ee51a262435c386e4aa9 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 10 Mar 2023 09:56:26 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F=20https://github.com/siyua?= =?UTF-8?q?n-note/siyuan/issues/7615?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/router.go | 6 +++--- kernel/api/system.go | 4 ++++ kernel/model/storage.go | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/api/router.go b/kernel/api/router.go index 902d24f7b..6e02101aa 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -52,14 +52,14 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/system/setAppearanceMode", model.CheckAuth, setAppearanceMode) ginServer.Handle("POST", "/api/system/getSysFonts", model.CheckAuth, getSysFonts) ginServer.Handle("POST", "/api/system/exit", model.CheckAuth, exit) - ginServer.Handle("POST", "/api/system/setUILayout", model.CheckAuth, model.CheckReadonly, setUILayout) + ginServer.Handle("POST", "/api/system/setUILayout", model.CheckAuth, setUILayout) ginServer.Handle("POST", "/api/system/getConf", model.CheckAuth, getConf) ginServer.Handle("POST", "/api/system/checkUpdate", model.CheckAuth, checkUpdate) ginServer.Handle("POST", "/api/system/exportLog", model.CheckAuth, exportLog) - ginServer.Handle("POST", "/api/storage/setLocalStorage", model.CheckAuth, model.CheckReadonly, setLocalStorage) + ginServer.Handle("POST", "/api/storage/setLocalStorage", model.CheckAuth, setLocalStorage) ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage) - ginServer.Handle("POST", "/api/storage/setLocalStorageVal", model.CheckAuth, model.CheckReadonly, setLocalStorageVal) + ginServer.Handle("POST", "/api/storage/setLocalStorageVal", model.CheckAuth, setLocalStorageVal) ginServer.Handle("POST", "/api/storage/removeLocalStorageVal", model.CheckAuth, model.CheckReadonly, removeLocalStorageVal) ginServer.Handle("POST", "/api/storage/setCriterion", model.CheckAuth, model.CheckReadonly, setCriterion) ginServer.Handle("POST", "/api/storage/getCriteria", model.CheckAuth, getCriteria) diff --git a/kernel/api/system.go b/kernel/api/system.go index a77659434..41c8def7b 100644 --- a/kernel/api/system.go +++ b/kernel/api/system.go @@ -171,6 +171,10 @@ func setUILayout(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) + if util.ReadOnly { + return + } + arg, ok := util.JsonArg(c, ret) if !ok { return diff --git a/kernel/model/storage.go b/kernel/model/storage.go index 1e8806780..8b91f4c50 100644 --- a/kernel/model/storage.go +++ b/kernel/model/storage.go @@ -325,6 +325,10 @@ func GetLocalStorage() (ret map[string]interface{}, err error) { } func setLocalStorage(val interface{}) (err error) { + if util.ReadOnly { + return + } + dirPath := filepath.Join(util.DataDir, "storage") if err = os.MkdirAll(dirPath, 0755); nil != err { logging.LogErrorf("create storage [local] dir failed: %s", err)