An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 改进判断工作空间路径实现 Fix https://github.com/siyuan-note/siyuan/issues/7569
Liang Ding3c9e80b4117b
diff --git a/kernel/api/workspace.go b/kernel/api/workspace.goindex fe2a4c145a..3b6b1510c3 100644--- a/kernel/api/workspace.go+++ b/kernel/api/workspace.go@@ -198,8 +198,10 @@ func setWorkspaceDir(c *gin.Context) {}if gulu.OS.IsWindows() {- installDir := filepath.Dir(util.WorkingDir)- if strings.HasPrefix(path, installDir) {+ // 改进判断工作空间路径实现 https://github.com/siyuan-note/siyuan/issues/7569+ installDirLower := strings.ToLower(filepath.Dir(util.WorkingDir))+ pathLower := strings.ToLower(path)+ if strings.HasPrefix(pathLower, installDirLower) && util.IsSubPath(installDirLower, pathLower) {ret.Code = -1ret.Msg = model.Conf.Language(98)ret.Data = map[string]interface{}{"closeTimeout": 5000}diff --git a/kernel/util/file.go b/kernel/util/file.goindex f39ebe0047..090956dcf4 100644--- a/kernel/util/file.go+++ b/kernel/util/file.go@@ -148,13 +148,13 @@ func FilterFileName(name string) string {return name}-func IsSubFolder(parent, sub string) bool {- if 1 > len(parent) || 1 > len(sub) {+func IsSubPath(absPath, toCheckPath string) bool {+ if 1 > len(absPath) || 1 > len(toCheckPath) {return false}if gulu.OS.IsWindows() {- if filepath.IsAbs(parent) && filepath.IsAbs(sub) {- if strings.ToLower(parent)[0] != strings.ToLower(sub)[0] {+ if filepath.IsAbs(absPath) && filepath.IsAbs(toCheckPath) {+ if strings.ToLower(absPath)[0] != strings.ToLower(toCheckPath)[0] {// 不在一个盘return false}@@ -162,7 +162,7 @@ func IsSubFolder(parent, sub string) bool {}up := ".." + string(os.PathSeparator)- rel, err := filepath.Rel(parent, sub)+ rel, err := filepath.Rel(absPath, toCheckPath)if err != nil {return false}