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