Avoid panic in s3 list operation (#2785)

This commit is contained in:
Vishal Nayak 2017-06-05 10:53:20 -04:00 committed by Jeff Mitchell
parent f7df60b131
commit c31b076360
1 changed files with 5 additions and 0 deletions

View File

@ -214,6 +214,11 @@ 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 {