forked from TrueCloudLab/distribution
Use 'prefix' parameter instead of 'path' when listing files
Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
parent
1d46bb2bcc
commit
3f9e7ed169
1 changed files with 8 additions and 4 deletions
|
@ -361,19 +361,23 @@ 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.
|
||||
func (d *driver) List(ctx context.Context, path string) ([]string, error) {
|
||||
var files []string
|
||||
|
||||
prefix := d.swiftPath(path)
|
||||
if prefix != "" {
|
||||
prefix += "/"
|
||||
}
|
||||
|
||||
opts := &swift.ObjectsOpts{
|
||||
Path: prefix,
|
||||
Prefix: prefix,
|
||||
Delimiter: '/',
|
||||
}
|
||||
|
||||
files, err := d.Conn.ObjectNames(d.Container, opts)
|
||||
for index, name := range files {
|
||||
files[index] = "/" + strings.TrimSuffix(name, "/")
|
||||
objects, err := d.Conn.Objects(d.Container, opts)
|
||||
for _, obj := range objects {
|
||||
if !obj.PseudoDirectory {
|
||||
files = append(files, "/"+strings.TrimSuffix(obj.Name, "/"))
|
||||
}
|
||||
}
|
||||
|
||||
return files, parseError(path, err)
|
||||
|
|
Loading…
Reference in a new issue