From 1554e000395959e465c77dbc3c187997b664e236 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Thu, 1 Jun 2023 17:21:31 +0200 Subject: [PATCH] Albums: Return all matching results when searching folders #3441 Signed-off-by: Michael Mayer --- internal/search/albums.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/search/albums.go b/internal/search/albums.go index a466a350f..8ae31328e 100644 --- a/internal/search/albums.go +++ b/internal/search/albums.go @@ -147,14 +147,12 @@ func UserAlbums(f form.SearchAlbums, sess *entity.Session) (results AlbumResults // Filter by title or path? if txt.NotEmpty(f.Query) { - if f.Type != entity.AlbumFolder { - likeString := "%" + f.Query + "%" - s = s.Where("albums.album_title LIKE ? OR albums.album_location LIKE ?", likeString, likeString) + q := "%" + strings.Trim(f.Query, " *%") + "%" + + if f.Type == entity.AlbumFolder { + s = s.Where("albums.album_title LIKE ? OR albums.album_location LIKE ? OR albums.album_path LIKE ?", q, q, q) } else { - searchQuery := strings.Trim(strings.ReplaceAll(f.Query, "\\", "/"), "/") - for _, where := range LikeAllNames(Cols{"albums.album_title", "albums.album_location", "albums.album_path"}, searchQuery) { - s = s.Where(where) - } + s = s.Where("albums.album_title LIKE ? OR albums.album_location LIKE ?", q, q) } }