Use 'prefix' parameter instead of 'path' when listing files

Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
Sylvain Baubeau 2015-06-04 10:11:19 +02:00
parent 1c01ca4b39
commit 3fb42a1502
1 changed files with 8 additions and 4 deletions

View File

@ -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)