From 67fc857cdd20245e5aa898276a4ca85cdf8d8d0b Mon Sep 17 00:00:00 2001 From: jonaustin09 Date: Thu, 3 Aug 2023 22:39:28 +0400 Subject: [PATCH] fix: Fixes #182, fixed max-keys 0 case to not return any object key --- backend/walk.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/walk.go b/backend/walk.go index 7d1e6b89..ed0aaff4 100644 --- a/backend/walk.go +++ b/backend/walk.go @@ -47,7 +47,7 @@ func Walk(fileSystem fs.FS, prefix, delimiter, marker string, max int32, getObj pastMarker = true } - var pastMax bool + pastMax := max == 0 var newMarker string var truncated bool @@ -55,6 +55,13 @@ func Walk(fileSystem fs.FS, prefix, delimiter, marker string, max int32, getObj if err != nil { return err } + // Ignore the root directory + if path == "." { + return nil + } + if contains(d.Name(), skipdirs) { + return fs.SkipDir + } if pastMax { newMarker = path @@ -63,15 +70,6 @@ func Walk(fileSystem fs.FS, prefix, delimiter, marker string, max int32, getObj } if d.IsDir() { - // Ignore the root directory - if path == "." { - return nil - } - - if contains(d.Name(), skipdirs) { - return fs.SkipDir - } - // If prefix is defined and the directory does not match prefix, // do not descend into the directory because nothing will // match this prefix. Make sure to append the / at the end of