driver/swift: treat empty object list as a PathNotFoundError

Swift returns an empty object list when trying to read a non-existing object path, treat it as a
PathNotFoundError when trying to list a non existing virtual directory.

Signed-off-by: David li <wenquan.li@hpe.com>
This commit is contained in:
davidli 2015-12-01 10:30:14 +08:00 committed by Stephen J Day
parent f25ccea279
commit 79d4d7f546

View file

@ -589,7 +589,7 @@ func (d *driver) List(ctx context.Context, path string) ([]string, error) {
files = append(files, strings.TrimPrefix(strings.TrimSuffix(obj.Name, "/"), d.swiftPath("/"))) files = append(files, strings.TrimPrefix(strings.TrimSuffix(obj.Name, "/"), d.swiftPath("/")))
} }
if err == swift.ContainerNotFound { if err == swift.ContainerNotFound || (len(objects) == 0 && path != "/") {
return files, storagedriver.PathNotFoundError{Path: path} return files, storagedriver.PathNotFoundError{Path: path}
} }
return files, err return files, err