Skip to content

Commit

Permalink
Support list start-after
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Oct 27, 2023
1 parent 02e0ce0 commit 46f2f72
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fakestorage/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ type ListOptions struct {
StartOffset string
EndOffset string
IncludeTrailingDelimiter bool
StartExclusive bool
}

// ListObjects returns a sorted list of objects that match the given criteria,
Expand Down Expand Up @@ -353,6 +354,9 @@ func (s *Server) ListObjectsWithOptions(bucketName string, options ListOptions)
if !strings.HasPrefix(obj.Name, options.Prefix) {
continue
}
if options.StartExclusive && obj.Name == options.StartOffset {
continue
}
objName := strings.Replace(obj.Name, options.Prefix, "", 1)
delimPos := strings.Index(objName, options.Delimiter)
if options.Delimiter != "" && delimPos > -1 {
Expand Down Expand Up @@ -577,9 +581,11 @@ func (s *Server) xmlListObjects(r *http.Request) xmlResponse {
bucketName := unescapeMuxVars(mux.Vars(r))["bucketName"]

opts := ListOptions{
Prefix: r.URL.Query().Get("prefix"),
Delimiter: r.URL.Query().Get("delimiter"),
Versions: r.URL.Query().Get("versions") == "true",
Prefix: r.URL.Query().Get("prefix"),
Delimiter: r.URL.Query().Get("delimiter"),
Versions: r.URL.Query().Get("versions") == "true",
StartOffset: r.URL.Query().Get("start-after"),
StartExclusive: true,
}

objs, prefixes, err := s.ListObjectsWithOptions(bucketName, opts)
Expand Down

0 comments on commit 46f2f72

Please sign in to comment.