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 import markdown assets path decoding https://github.com/siyuan-note/siyuan/issues/14033
Daniel1f6d327f24a7
diff --git a/kernel/model/import.go b/kernel/model/import.goindex bafd50d1ef..87dd85ddb5 100644--- a/kernel/model/import.go+++ b/kernel/model/import.go@@ -866,8 +866,16 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {return ast.WalkContinue}- dest = strings.ReplaceAll(dest, "%20", " ")- dest = strings.ReplaceAll(dest, "%5C", "/")+ absolutePath := filepath.Join(localPath, dest)+ newAbsolutePath := absolutePath++ decodedDest := string(html.DecodeDestination([]byte(dest)))+ if decodedDest != dest {+ dest = decodedDest+ newAbsolutePath = filepath.Join(localPath, dest)+ gulu.File.Copy(absolutePath, newAbsolutePath)+ }+if ast.NodeLinkDest == n.Type {n.Tokens = []byte(dest)} else {@@ -881,6 +889,10 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {return ast.WalkContinue}+ if !gulu.File.IsExist(newAbsolutePath) {+ return ast.WalkContinue+ }+absDest := filepath.Join(currentDir, dest)fullPath, exist := assets[absDest]if !exist {@@ -988,8 +1000,16 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {return ast.WalkContinue}- dest = strings.ReplaceAll(dest, "%20", " ")- dest = strings.ReplaceAll(dest, "%5C", "/")+ absolutePath := filepath.Join(filepath.Dir(localPath), dest)+ newAbsolutePath := absolutePath++ decodedDest := string(html.DecodeDestination([]byte(dest)))+ if decodedDest != dest {+ dest = decodedDest+ newAbsolutePath = filepath.Join(filepath.Dir(localPath), dest)+ gulu.File.Copy(absolutePath, newAbsolutePath)+ }+if ast.NodeLinkDest == n.Type {n.Tokens = []byte(dest)} else {@@ -1003,25 +1023,21 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {return ast.WalkContinue}- absolutePath := filepath.Join(filepath.Dir(localPath), dest)- exist := gulu.File.IsExist(absolutePath)- if !exist {- absolutePath = filepath.Join(filepath.Dir(localPath), string(html.DecodeDestination([]byte(dest))))- exist = gulu.File.IsExist(absolutePath)- }- if exist {- name := filepath.Base(absolutePath)- name = util.AssetName(name)- assetTargetPath := filepath.Join(assetDirPath, name)- if err = filelock.Copy(absolutePath, assetTargetPath); err != nil {- logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", absolutePath, assetTargetPath, err)- return ast.WalkContinue- }- if ast.NodeLinkDest == n.Type {- n.Tokens = []byte("assets/" + name)- } else {- n.TextMarkAHref = "assets/" + name- }+ if !gulu.File.IsExist(newAbsolutePath) {+ return ast.WalkContinue+ }++ name := filepath.Base(newAbsolutePath)+ name = util.AssetName(name)+ assetTargetPath := filepath.Join(assetDirPath, name)+ if err = filelock.Copy(newAbsolutePath, assetTargetPath); err != nil {+ logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", newAbsolutePath, assetTargetPath, err)+ return ast.WalkContinue+ }+ if ast.NodeLinkDest == n.Type {+ n.Tokens = []byte("assets/" + name)+ } else {+ n.TextMarkAHref = "assets/" + name}return ast.WalkContinue})