Skip to content

Commit

Permalink
Add another nil guard to S3, follow on from #2785
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Jun 5, 2017
1 parent a337f9f commit c655dee
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions physical/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,22 @@ func (s *S3Backend) List(prefix string) ([]string, error) {

err := s.client.ListObjectsV2Pages(params,
func(page *s3.ListObjectsV2Output, lastPage bool) bool {
for _, key := range page.Contents {
// Avoid panic
if key == nil {
continue
}

key := strings.TrimPrefix(*key.Key, prefix)

if i := strings.Index(key, "/"); i == -1 {
// Add objects only from the current 'folder'
keys = append(keys, key)
} else if i != -1 {
// Add truncated 'folder' paths
keys = appendIfMissing(keys, key[:i+1])
if page != nil {
for _, key := range page.Contents {
// Avoid panic
if key == nil {
continue
}

key := strings.TrimPrefix(*key.Key, prefix)

if i := strings.Index(key, "/"); i == -1 {
// Add objects only from the current 'folder'
keys = append(keys, key)
} else if i != -1 {
// Add truncated 'folder' paths
keys = appendIfMissing(keys, key[:i+1])
}
}
}
return true
Expand Down

0 comments on commit c655dee

Please sign in to comment.