From 0d1e9dfee88c9ccb35b21a0e24d664025b090f0b Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Sun, 1 Jun 2025 13:23:28 +0200 Subject: [PATCH] Backend: Added 'ignore_folder' inside the photo path. --- backend/core/file.go | 2 +- backend/util/config.go | 5 ++++- backend/util/util.go | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/core/file.go b/backend/core/file.go index 07bf7ed..201788f 100644 --- a/backend/core/file.go +++ b/backend/core/file.go @@ -43,7 +43,7 @@ func listFiles(path string, actualdir string, picd []PictureData) []PictureData continue } - if info.IsDir() { + if info.IsDir() && !util.StringInSlice(info.Name(), util.GetConfig().IgnoreFolder) { // fmt.Printf("\uf07b %s\n", entry.Name()) picd = listFiles(path+"/"+info.Name(), info.Name(), picd) } else { diff --git a/backend/util/config.go b/backend/util/config.go index 589586f..59fcd9c 100644 --- a/backend/util/config.go +++ b/backend/util/config.go @@ -8,11 +8,13 @@ import ( ) type ConfigJSON struct { - PhotoPath string + PhotoPath string `json:"photo_path"` + IgnoreFolder []string `json:"ignore_folder"` } type Config struct { PhotoPath string + IgnoreFolder []string PhotoCompressPath string } @@ -42,6 +44,7 @@ func ReadConfig(path string) (Config, error) { decoder.DisallowUnknownFields() err = decoder.Decode(&cfg) main_config.PhotoPath = cfg.PhotoPath + main_config.IgnoreFolder = cfg.IgnoreFolder return main_config, err } diff --git a/backend/util/util.go b/backend/util/util.go index 682da95..42aacc5 100644 --- a/backend/util/util.go +++ b/backend/util/util.go @@ -29,3 +29,12 @@ func InputString(print string) string { } return strings.TrimSpace(input) } + +func StringInSlice(s string, list []string) bool { + for _, v := range list { + if v == s { + return true + } + } + return false +}