From 3d37de0ec53e940f05b6a880b0017d23963da60a Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Thu, 7 Dec 2023 22:00:33 +0100 Subject: [PATCH] fix: List single dirs --- internal/drivers/s3.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/drivers/s3.go b/internal/drivers/s3.go index e1baea0..7ed0f80 100644 --- a/internal/drivers/s3.go +++ b/internal/drivers/s3.go @@ -59,7 +59,19 @@ func (d *S3Driver) ListDirs(path string) ([]string, error) { res = append(res, strings.Split(strings.Replace(i, path, "", 1), "/")[0]) } - return res, err + return removeDuplicateStr(res), err +} + +func removeDuplicateStr(strSlice []string) []string { + allKeys := make(map[string]bool) + list := []string{} + for _, item := range strSlice { + if _, value := allKeys[item]; !value { + allKeys[item] = true + list = append(list, item) + } + } + return list } func (d *S3Driver) listRaw(path string) ([]string, error) {