filter listResponse.Contents in driver.List()
Signed-off-by: Kira <me@imkira.com>
This commit is contained in:
parent
7694c31658
commit
4accc8f2be
1 changed files with 8 additions and 2 deletions
|
@ -351,7 +351,8 @@ func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
|
||||||
prefix = "/"
|
prefix = "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
listResponse, err := d.Bucket.List(d.ossPath(path), "/", "", listMax)
|
ossPath := d.ossPath(path)
|
||||||
|
listResponse, err := d.Bucket.List(ossPath, "/", "", listMax)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, parseError(opath, err)
|
return nil, parseError(opath, err)
|
||||||
}
|
}
|
||||||
|
@ -369,7 +370,7 @@ func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if listResponse.IsTruncated {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -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 opath != "/" {
|
||||||
if len(files) == 0 && len(directories) == 0 {
|
if len(files) == 0 && len(directories) == 0 {
|
||||||
// Treat empty response as missing directory, since we don't actually
|
// Treat empty response as missing directory, since we don't actually
|
||||||
|
|
Loading…
Reference in a new issue