This commit is contained in:
Daniel 2024-11-14 23:51:27 +08:00
parent e164e88dc4
commit 9681fe6d80
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -752,7 +752,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
targetPath = strings.ReplaceAll(targetPath, ".sy/", "/")
targetPath += ".sy"
targetPaths[curRelPath] = targetPath
if _, ok := targetPaths[curRelPath]; !ok {
targetPaths[curRelPath] = targetPath
} else {
targetPath = targetPaths[curRelPath]
id = strings.TrimSuffix(path.Base(targetPath), ".sy")
}
if info.IsDir() {
if subMdFiles := util.GetFilePathsByExts(currentPath, []string{".md", ".markdown"}); 1 > len(subMdFiles) {
@ -760,6 +765,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
return nil
}
// 如果当前文件夹路径下包含同名的 Markdown 文件,则不创建空文档 https://github.com/siyuan-note/siyuan/issues/13149
if gulu.File.IsExist(currentPath+".md") || gulu.File.IsExist(currentPath+".markdown") {
targetPaths[curRelPath+".md"] = targetPath
return nil
}
tree = treenode.NewTree(boxID, targetPath, hPath, title)
importTrees = append(importTrees, tree)
return nil