Explorar el Código

:bug: 设置代码片段报错 Fix https://github.com/siyuan-note/siyuan/issues/6382

Liang Ding hace 2 años
padre
commit
b194f803d5
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  1. 7 2
      kernel/model/snippet.go

+ 7 - 2
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
 }