From f39e561af773ce9e90142553847360db8f6acf48 Mon Sep 17 00:00:00 2001 From: Graham Steffaniak Date: Mon, 31 Jul 2023 17:20:14 -0500 Subject: [PATCH] updated a bit --- backend/search/indexing.go | 13 ++-- frontend/src/components/Search.vue | 95 ++++++++++-------------------- frontend/src/css/base.css | 5 +- frontend/src/css/header.css | 14 ++++- 4 files changed, 53 insertions(+), 74 deletions(-) diff --git a/backend/search/indexing.go b/backend/search/indexing.go index c11ac4ed..4b9f0b43 100644 --- a/backend/search/indexing.go +++ b/backend/search/indexing.go @@ -184,6 +184,7 @@ func containsSearchTerm(pathName string, searchTerm string, options searchOption fileTypes := map[string]bool{} fileSize := getFileSize(pathName) matchesCondition := false + matchesAllConditions := true extension := filepath.Ext(strings.ToLower(path)) mimetype := mime.TypeByExtension(extension) fileTypes["audio"] = strings.HasPrefix(mimetype, "audio") @@ -192,7 +193,7 @@ func containsSearchTerm(pathName string, searchTerm string, options searchOption fileTypes["doc"] = isDoc(extension) fileTypes["archive"] = isArchive(extension) fileTypes["dir"] = isDir - anyFilter := false + for t,v := range conditions { switch t { case "exact" : continue @@ -200,12 +201,12 @@ func containsSearchTerm(pathName string, searchTerm string, options searchOption case "smaller" : matchesCondition = fileSize < int64(options.Size) * 1000000 default : matchesCondition = v == fileTypes[t] } - anyFilter = true + if (!matchesCondition) { + matchesAllConditions = false + } } - if !anyFilter { - matchesCondition = true - } - return matchesCondition, fileTypes + + return matchesAllConditions, fileTypes } return false, map[string]bool{} } diff --git a/frontend/src/components/Search.vue b/frontend/src/components/Search.vue index c4823010..e0e1bdc1 100644 --- a/frontend/src/components/Search.vue +++ b/frontend/src/components/Search.vue @@ -1,26 +1,12 @@