Skip to content

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

:art: Improve move doc

Daniel84c801bbc958
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 046534a1d8..e49ebcbe9f 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1238,6 +1238,16 @@ func MoveDocs(fromPaths []string, toBoxID, toPath string, callback interface{})
pathsBoxes := getBoxesByPaths(fromPaths)
+ if 1 == len(fromPaths) {
+ // 移动到自己的父文档下的情况相当于不移动,直接返回
+ if fromBox := pathsBoxes[fromPaths[0]]; nil != fromBox && fromBox.ID == toBoxID {
+ parentDir := path.Dir(fromPaths[0])
+ if ("/" == toPath && "/" == parentDir) || (parentDir+".sy" == toPath) {
+ return
+ }
+ }
+ }
+
// 检查路径深度是否超过限制
for fromPath, fromBox := range pathsBoxes {
childDepth := util.GetChildDocDepth(filepath.Join(util.DataDir, fromBox.ID, fromPath))