storage/driver/s3: adjust s3 driver to return unmunged path
This fixes both the s3 driver and the oss driver to return the unmunged path when returning errors. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
533c912d3e
commit
d68acc869e
2 changed files with 23 additions and 17 deletions
|
@ -651,8 +651,9 @@ func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns a list of the objects that are direct descendants of the given path.
|
// List returns a list of the objects that are direct descendants of the given path.
|
||||||
func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
|
||||||
if path != "/" && path[len(path)-1] != '/' {
|
path := opath
|
||||||
|
if path != "/" && opath[len(path)-1] != '/' {
|
||||||
path = path + "/"
|
path = path + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,13 +667,7 @@ func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
||||||
|
|
||||||
listResponse, err := d.Bucket.List(d.ossPath(path), "/", "", listMax)
|
listResponse, err := d.Bucket.List(d.ossPath(path), "/", "", listMax)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, parseError(path, err)
|
return nil, parseError(opath, err)
|
||||||
}
|
|
||||||
|
|
||||||
if len(listResponse.Contents) == 0 && path != "/" {
|
|
||||||
// Treat empty response as missing directory, since we don't actually
|
|
||||||
// have directories in OSS.
|
|
||||||
return nil, storagedriver.PathNotFoundError{Path: path}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
files := []string{}
|
files := []string{}
|
||||||
|
@ -697,6 +692,14 @@ func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opath != "/" {
|
||||||
|
if len(files) == 0 && len(directories) == 0 {
|
||||||
|
// Treat empty response as missing directory, since we don't actually
|
||||||
|
// have directories in s3.
|
||||||
|
return nil, storagedriver.PathNotFoundError{Path: opath}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return append(files, directories...), nil
|
return append(files, directories...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -667,7 +667,8 @@ func (d *driver) Stat(ctx context.Context, path string) (storagedriver.FileInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
// List returns a list of the objects that are direct descendants of the given path.
|
// List returns a list of the objects that are direct descendants of the given path.
|
||||||
func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
func (d *driver) List(ctx context.Context, opath string) ([]string, error) {
|
||||||
|
path := opath
|
||||||
if path != "/" && path[len(path)-1] != '/' {
|
if path != "/" && path[len(path)-1] != '/' {
|
||||||
path = path + "/"
|
path = path + "/"
|
||||||
}
|
}
|
||||||
|
@ -682,13 +683,7 @@ func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
||||||
|
|
||||||
listResponse, err := d.Bucket.List(d.s3Path(path), "/", "", listMax)
|
listResponse, err := d.Bucket.List(d.s3Path(path), "/", "", listMax)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, parseError(opath, err)
|
||||||
}
|
|
||||||
|
|
||||||
if len(listResponse.Contents) == 0 {
|
|
||||||
// Treat empty response as missing directory, since we don't actually
|
|
||||||
// have directories in s3.
|
|
||||||
return nil, storagedriver.PathNotFoundError{Path: path}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
files := []string{}
|
files := []string{}
|
||||||
|
@ -713,6 +708,14 @@ func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opath != "/" {
|
||||||
|
if len(files) == 0 && len(directories) == 0 {
|
||||||
|
// Treat empty response as missing directory, since we don't actually
|
||||||
|
// have directories in s3.
|
||||||
|
return nil, storagedriver.PathNotFoundError{Path: opath}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return append(files, directories...), nil
|
return append(files, directories...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue