From d6d54a45bda6a1721c5b30f4ac9a582d24f20ec2 Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Thu, 12 Dec 2024 14:35:37 +0200 Subject: [PATCH] fix find by name Signed-off-by: Ivan Milchev --- providers/os/connection/tar/fs.go | 2 +- providers/os/resources/files.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/providers/os/connection/tar/fs.go b/providers/os/connection/tar/fs.go index 5eb4acae96..14de7b058c 100644 --- a/providers/os/connection/tar/fs.go +++ b/providers/os/connection/tar/fs.go @@ -209,7 +209,7 @@ func (fs *FS) Find(from string, r *regexp.Regexp, typ string, perm *uint32, dept log.Trace().Str("path", k).Str("from", from).Str("prefix", from).Bool("prefix", p).Bool("m", m).Msg("check if matches") if p && m { entry := fs.FileMap[k] - if (typ == "directory" && entry.Typeflag == tar.TypeDir) || (typ == "file" && entry.Typeflag == tar.TypeReg) { + if (typ == "directory" && entry.Typeflag == tar.TypeDir) || (typ == "file" && entry.Typeflag == tar.TypeReg) || typ == "" { list = append(list, k) log.Debug().Msg("matches") continue diff --git a/providers/os/resources/files.go b/providers/os/resources/files.go index 27ac507f21..6a5431e5a9 100644 --- a/providers/os/resources/files.go +++ b/providers/os/resources/files.go @@ -70,6 +70,11 @@ func (l *mqlFilesFind) list() ([]interface{}, error) { if err != nil { return nil, err } + } else if len(l.Name.Data) > 0 { + compiledRegexp, err = regexp.Compile(l.Name.Data) + if err != nil { + return nil, err + } } var foundFiles []string