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