Speedup filesystem walking by removing calling os.Lstat on each item

This commit is contained in:
nxshock 2023-03-17 21:16:04 +05:00
parent 8762ea898f
commit 959a356153

View File

@ -348,7 +348,7 @@ func (b *Config) index() (*Index, error) {
fileMask := filepath.Join(filepath.Dir(b.filePath), b.FileName+"*"+defaultExt) fileMask := filepath.Join(filepath.Dir(b.filePath), b.FileName+"*"+defaultExt)
var files []string var files []string
err := filepath.Walk(filepath.Dir(b.filePath), func(path string, info os.FileInfo, err error) error { err := filepath.WalkDir(filepath.Dir(b.filePath), func(path string, info os.DirEntry, err error) error {
matched, err := filepath.Match(fileMask, path) matched, err := filepath.Match(fileMask, path)
if err != nil { if err != nil {
return fmt.Errorf("filepath.Match: %v", err) return fmt.Errorf("filepath.Match: %v", err)