Skip to content

Commit

Permalink
Merge pull request #2070 from kdada/master
Browse files Browse the repository at this point in the history
filter listResponse.Contents in OSS driver.List()
  • Loading branch information
dmcgowan authored Dec 5, 2016
2 parents c599955 + 4accc8f commit 314144a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions registry/storage/driver/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
prefix = "/"
}

listResponse, err := d.Bucket.List(d.ossPath(path), "/", "", listMax)
ossPath := d.ossPath(path)
listResponse, err := d.Bucket.List(ossPath, "/", "", listMax)
if err != nil {
return nil, parseError(opath, err)
}
Expand All @@ -369,7 +370,7 @@ func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
}

if listResponse.IsTruncated {
listResponse, err = d.Bucket.List(d.ossPath(path), "/", listResponse.NextMarker, listMax)
listResponse, err = d.Bucket.List(ossPath, "/", listResponse.NextMarker, listMax)
if err != nil {
return nil, err
}
Expand All @@ -378,6 +379,11 @@ func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
}
}

// This is to cover for the cases when the first key equal to ossPath.
if len(files) > 0 && files[0] == strings.Replace(ossPath, d.ossPath(""), prefix, 1) {
files = files[1:]
}

if opath != "/" {
if len(files) == 0 && len(directories) == 0 {
// Treat empty response as missing directory, since we don't actually
Expand Down

0 comments on commit 314144a

Please sign in to comment.