Skip to content

Commit

Permalink
Merge pull request #88 from Alfus/alfus/startAfter
Browse files Browse the repository at this point in the history
Fix startAfter when object is not present
  • Loading branch information
johannesboyne authored Feb 17, 2024
2 parents f7e9c41 + b359e41 commit c55a48f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions backend/s3mem/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ func (db *Backend) ListBucket(name string, prefix *gofakes3.Prefix, page gofakes

if page.Marker != "" {
iter.Seek(page.Marker)
iter.Next() // Move to the next item after the Marker
// If the current item is the Marker, move to the next item.
if iter.Key() == page.Marker {
iter.Next()
}
}

var cnt int64 = 0
Expand All @@ -102,18 +105,18 @@ func (db *Backend) ListBucket(name string, prefix *gofakes3.Prefix, page gofakes
for iter.Next() {
item := iter.Value().(*bucketObject)

if !prefix.Match(item.data.name, &match) {
switch {
case !prefix.Match(item.data.name, &match):
continue
} else if item.data.deleteMarker {
case item.data.deleteMarker:
continue
} else if match.CommonPrefix {
case match.CommonPrefix:
if match.MatchedPart == lastMatchedPart {
continue // Should not count towards keys
}
response.AddPrefix(match.MatchedPart)
lastMatchedPart = match.MatchedPart

} else {
default:
response.Add(&gofakes3.Content{
Key: item.data.name,
LastModified: gofakes3.NewContentTime(item.data.lastModified),
Expand Down

0 comments on commit c55a48f

Please sign in to comment.