Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Liang Dingb194f803d588
diff --git a/kernel/model/snippet.go b/kernel/model/snippet.go
index 416d261a9f..ed73c9835e 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
}