Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-05-29 21:24:06 +08:00
commit 25287f04b7
5 changed files with 31 additions and 4 deletions

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866
github.com/88250/lute v1.7.7-0.20240527023817-011086d31ec0
github.com/88250/lute v1.7.7-0.20240529025122-c2b54f422dc4
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4

View file

@ -12,8 +12,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866 h1:RFfNFS0hv6TbOuwET6xZAfGlV4hNlXiWTnfbLN1eF6k=
github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
github.com/88250/lute v1.7.7-0.20240527023817-011086d31ec0 h1:4tNp+bBM10JqvYD9H0AeHhVYcPm1RDcvnblV94vQ7lw=
github.com/88250/lute v1.7.7-0.20240527023817-011086d31ec0/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/lute v1.7.7-0.20240529025122-c2b54f422dc4 h1:5/vRlAP/3C7YG7KMd35OlHIgNwMx3s6QLBwcjx8YABw=
github.com/88250/lute v1.7.7-0.20240529025122-c2b54f422dc4/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

View file

@ -713,6 +713,11 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
targetPaths[curRelPath] = targetPath
if 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 nil

View file

@ -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