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: Improve importing Markdown folder https://github.com/siyuan-note/siyuan/issues/11567
Daniel36493a8a3ab9
diff --git a/kernel/model/import.go b/kernel/model/import.goindex 0ca9714f39..439a96dc34 100644--- a/kernel/model/import.go+++ b/kernel/model/import.go@@ -713,6 +713,11 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {targetPaths[curRelPath] = targetPathif info.IsDir() {+ if subMdFiles := util.GetFilePathsByExts(currentPath, []string{".md", ".markdown"}); 1 > len(subMdFiles) {+ // 如果该文件夹中不包含 Markdown 文件则不处理 https://github.com/siyuan-note/siyuan/issues/11567+ return nil+ }+tree = treenode.NewTree(boxID, targetPath, hPath, title)importTrees = append(importTrees, tree)return nildiff --git a/kernel/util/file.go b/kernel/util/file.goindex 75c19ed829..c6376269ea 100644--- a/kernel/util/file.go+++ b/kernel/util/file.go@@ -35,6 +35,28 @@ import ("github.com/siyuan-note/logging")+func GetFilePathsByExts(dirPath string, exts []string) (ret []string) {+ filelock.Walk(dirPath, func(path string, info os.FileInfo, err error) error {+ if nil != err {+ logging.LogErrorf("get file paths by ext failed: %s", err)+ return err+ }++ if info.IsDir() {+ return nil+ }++ for _, ext := range exts {+ if strings.HasSuffix(path, ext) {+ ret = append(ret, path)+ break+ }+ }+ return nil+ })+ return+}+func GetUniqueFilename(filePath string) string {if !gulu.File.IsExist(filePath) {return filePath