Skip to content

Commit

Permalink
fix: List single dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Dec 7, 2023
1 parent 55d7653 commit 3d37de0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/drivers/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3d37de0

Please sign in to comment.