Resolve symlink root in search

This commit is contained in:
2026-04-29 14:17:52 +02:00
parent dd3906855d
commit 511b65df22
+10 -3
View File
@@ -57,8 +57,15 @@ func searchFolders(root, query string) []searchResult {
maxDist = 3
}
// Resolve symlinks so WalkDir descends into the real tree even when the
// configured wiki root is itself a symlink (as on the deployed NAS).
walkRoot, err := filepath.EvalSymlinks(root)
if err != nil {
walkRoot = root
}
var results []searchResult
_ = filepath.WalkDir(root, func(fsPath string, d fs.DirEntry, err error) error {
_ = filepath.WalkDir(walkRoot, func(fsPath string, d fs.DirEntry, err error) error {
if err != nil {
return nil
}
@@ -69,14 +76,14 @@ func searchFolders(root, query string) []searchResult {
}
return nil
}
if !d.IsDir() || fsPath == root {
if !d.IsDir() || fsPath == walkRoot {
return nil
}
rank, ok := matchRank(strings.ToLower(name), q, maxDist)
if !ok {
return nil
}
rel, relErr := filepath.Rel(root, fsPath)
rel, relErr := filepath.Rel(walkRoot, fsPath)
if relErr != nil {
return nil
}