From b194f803d588dfa75ee06311fcaf53a5f1dbbd00 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 28 Oct 2022 09:31:45 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E8=AE=BE=E7=BD=AE=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=89=87=E6=AE=B5=E6=8A=A5=E9=94=99=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/6382?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/snippet.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/model/snippet.go b/kernel/model/snippet.go index 416d261a9..ed73c9835 100644 --- a/kernel/model/snippet.go +++ b/kernel/model/snippet.go @@ -17,6 +17,7 @@ package model import ( + "os" "path/filepath" "sync" @@ -66,7 +67,7 @@ func LoadSnippets() (ret []*conf.Snippet, err error) { func loadSnippets() (ret []*conf.Snippet, err error) { ret = []*conf.Snippet{} - confPath := filepath.Join(util.DataDir, "snippets/conf.json") + confPath := filepath.Join(util.SnippetsPath, "conf.json") if !gulu.File.IsExist(confPath) { return } @@ -102,7 +103,11 @@ func writeSnippetsConf(snippets []*conf.Snippet) (err error) { return } - confPath := filepath.Join(util.DataDir, "snippets/conf.json") + if err = os.MkdirAll(util.SnippetsPath, 0755); nil != err { + return + } + + confPath := filepath.Join(util.SnippetsPath, "conf.json") err = filelock.WriteFile(confPath, data) return }