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

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. // 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, path string) ([]string, error) {
var files []string
prefix := d.swiftPath(path) prefix := d.swiftPath(path)
if prefix != "" { if prefix != "" {
prefix += "/" prefix += "/"
} }
opts := &swift.ObjectsOpts{ opts := &swift.ObjectsOpts{
Path: prefix, Prefix: prefix,
Delimiter: '/', Delimiter: '/',
} }
files, err := d.Conn.ObjectNames(d.Container, opts) objects, err := d.Conn.Objects(d.Container, opts)
for index, name := range files { for _, obj := range objects {
files[index] = "/" + strings.TrimSuffix(name, "/") if !obj.PseudoDirectory {
files = append(files, "/"+strings.TrimSuffix(obj.Name, "/"))
}
} }
return files, parseError(path, err) return files, parseError(path, err)