mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
de2a414968
2 changed files with 9 additions and 4 deletions
|
|
@ -70,6 +70,10 @@ func SearchTemplate(keyword string) (ret []*Block) {
|
|||
ret = []*Block{}
|
||||
|
||||
templates := filepath.Join(util.DataDir, "templates")
|
||||
if !util.IsPathRegularDirOrSymlinkDir(templates) {
|
||||
return
|
||||
}
|
||||
|
||||
groups, err := os.ReadDir(templates)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read templates failed: %s", err)
|
||||
|
|
@ -89,10 +93,11 @@ func SearchTemplate(keyword string) (ret []*Block) {
|
|||
if group.IsDir() {
|
||||
var templateBlocks []*Block
|
||||
templateDir := filepath.Join(templates, group.Name())
|
||||
filepath.Walk(templateDir, func(path string, info fs.FileInfo, err error) error {
|
||||
name := strings.ToLower(info.Name())
|
||||
// filepath.Walk 与 filepath.WalkDir 均不支持跟踪符号链接
|
||||
filepath.WalkDir(templateDir, func(path string, entry fs.DirEntry, err error) error {
|
||||
name := strings.ToLower(entry.Name())
|
||||
if strings.HasPrefix(name, ".") {
|
||||
if info.IsDir() {
|
||||
if entry.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func SearchWidget(keyword string) (ret []*Block) {
|
|||
|
||||
k := strings.ToLower(keyword)
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
if !util.IsDirRegularOrSymlink(entry) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue