From 257ed55de7eea2d9ba766595df7d414a9d2af836 Mon Sep 17 00:00:00 2001 From: Simon Behar Date: Thu, 11 Mar 2021 11:17:49 -0800 Subject: [PATCH] fix: Do not clean empty keyPrefix (#39) Signed-off-by: Simon Behar --- s3/s3.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/s3/s3.go b/s3/s3.go index eedf3f89..a898a179 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -257,9 +257,12 @@ func (s *s3client) IsDirectory(bucket, key string) (bool, error) { func (s *s3client) ListDirectory(bucket, keyPrefix string) ([]string, error) { log.Infof("Listing directory from s3 (endpoint: %s, bucket: %s, key: %s)", s.Endpoint, bucket, keyPrefix) - keyPrefix = filepath.Clean(keyPrefix) + "/" - if os.PathSeparator == '\\' { - keyPrefix = strings.ReplaceAll(keyPrefix, "\\", "/") + + if keyPrefix != "" { + keyPrefix = filepath.Clean(keyPrefix) + "/" + if os.PathSeparator == '\\' { + keyPrefix = strings.ReplaceAll(keyPrefix, "\\", "/") + } } doneCh := make(chan struct{})